//我的版本
// ///////////////////////////////公共部分///////////////////////////////////////////
var autourl=new Array();
var tim = 1;
var b = 1;
var fjxxsl=0;// 房间信息数量
var fjxxzs=10// 房间信息总数
var timeouttime = 8000;// 超时时间

var mark = 0;
var cj_money = 5;
var onetimeArray = new Array();
var boxtimeArray = new Array();
var PUBLIC_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClcAVq4FbUSGgXqiyLEStwQTgBGSnyAirPGaZb7tLH4GgF7MNjaeUBXq48zF8mvpTmeRieHiOnbJrnenYzrKQ727x8IXUb8jECLMHQgzfsd0A/rrkshiXnz+6UVJWyioW811FL9OPJIkwsItUhNK3s+/5wsSqJtvsMsH+m01NKAwIDAQAB';
var lotteryObj = new Object();// 彩种第三玩法存储器
var lotteryPageObj = new Object();// 彩票页存储器
var lotteryFjPageObj = new Object();// 房间页面存储器
var wfsmObj = new Object();// 玩法说明存储器
var mainObj = '';
var mainPageObj = new Object();// 主页
var fjjlxx = new Object();// 房间进入信息
var fjfpxx = new Object();// 房间封盘信息
var pagesize = 10;
var pagenum = 1;

var chips_str = "";
// //////////////////////////////////////////////////////////////////////
/**
 * 清第三玩法存储器
 */
function delLotteryObj(){
	for(var key in lotteryObj) {
	    delete lotteryObj[key]
	}
}
/**
 * 清彩票页存储器
 */
function delLotteryPageObj(){
	for(var key in lotteryPageObj) {
	    delete lotteryPageObj[key]
	}
}
/**
 * 清房间页面存储器
 */
function delLotteryFjPageObj(){
	for(var key in lotteryFjPageObj) {
	    delete lotteryFjPageObj[key]
	}
}

/**
 * 清房间页面存储器
 */
function delFjjlxxObj(){
	for(var key in fjjlxx) {
	    delete fjjlxx[key]
	}
}

/**
 * 清房间页面存储器
 */
function delFjfpxxObj(){
	for(var key in fjfpxx) {
	    delete fjfpxx[key]
	}
}
/**
 * 清除玩法说明存储器
 * 
 * @returns
 */
function delWfsmObj(){
	for(var key in wfsmObj) {
	    delete wfsmObj[key]
	}
}
// /////////////////////移除房间信息/////////////////////////////////////////////////
/**
 * 移除房间信息
 */
function removeFjxx(str){
	fjxxsl = $("#fjtzhm").children('li').length;
	if(fjxxsl>fjxxzs){
		$("#fjtzhm").children('li:first').remove();
	}
	$("#fjtzhm").append(str);
}
// /////////////////////////房间信息//////////////////////////////////////
// 房间开奖信息
function getFjfpxx(wfbm1){
	if(fjfpxx[wfbm1]==undefined || fjfpxx[wfbm1]==''){
		$.ajax({
			url : "lottery/getFjfpxx.do",
			type : "POST",
			data : {"wfbm1":wfbm1},
			dataType : "text",
			success : function(data) {
				fjfpxx[wfbm1]=data;
				var fjxtxx2 = "<li class='am-comment' style='margin-top: 0'>"+
									"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
									"<p class='sys-alert'>"+
										"<span class='sys-staus text-blue iottb'>系统消息</span>"+
									    "<span class='sys-text'>"+fjfpxx[wfbm1]+
									        "</span>"+
									"</p>"+
								"</li>";
// $("#fjtzhm").append(fjxtxx2);
				removeFjxx(fjxtxx2);
			},
			error : function(x, h, e) {
				load_closeAll();
			}
		});
	}else{
		var fjxtxx1 = "<li class='am-comment' style='margin-top: 0'>"+
						"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
						"<p class='sys-alert'>"+
							"<span class='sys-staus text-blue iottb'>系统消息</span>"+
						    "<span class='sys-text'>"+fjfpxx[wfbm1]+
						        "</span>"+
						"</p>"+
					"</li>";
// $("#fjtzhm").append(fjxtxx1);
		removeFjxx(fjxtxx1);
	}
}
/**
 * 房间进入信息
 */
function getFjjlxx(wfbm1){
	if(fjjlxx[wfbm1]==undefined || fjjlxx[wfbm1]==''){
			$.ajax({
				url : "lottery/getFjjlxx.do",
				type : "POST",
				data : {"wfbm1":wfbm1},
				dataType : "text",
				success : function(data) {
					fjjlxx[wfbm1]=data;
					var fjxtxx2 = "<li class='am-comment' style='margin-top: 0'>"+
										"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
										"<p class='sys-alert'>"+
											"<span class='sys-staus text-blue iottb'>系统消息</span>"+
										    "<span class='sys-text'>"+fjjlxx[wfbm1]+
										        "</span>"+
										"</p>"+
									"</li>";
// $("#fjtzhm").append(fjxtxx2);
					removeFjxx(fjxtxx2);
				},
				error : function(x, h, e) {
					load_closeAll();
				}
			});
	}else{
		var fjxtxx2 = "<li class='am-comment' style='margin-top: 0'>"+
						"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
						"<p class='sys-alert'>"+
							"<span class='sys-staus text-blue iottb'>系统消息</span>"+
						    "<span class='sys-text'>"+fjjlxx[wfbm1]+
						        "</span>"+
						"</p>"+
					"</li>";
	    $("#fjtzhm").append(fjxtxx2);
	}
}



// ////////////////////////红包//////////////////////////////////////
function getHbIsInit(){
	var index = load_open();
	$.ajax({
		url : "lottery/getHbIsInit.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data.sflq=='0'){
				getHbInit(data);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function getHbInit(obj){
	$("#hb").attr("style","display:block");
	if(obj.sfhb!='undefined'&&obj.sfhb=='1' && obj.sflq=='0'){
		$("#hb").on("click",function(){
			$("#hb").attr("style","display:none");
			red();
		});
	}else{
			$("#hb").on("click",function(){
				if($("#gly").val()=="-1" || $("#gly").val()=="0" || $("#gly").val()=="1"){
// layer.alert("正在加紧如建设中。。。");
					getHbsm();
				}else{
					// 询问框
					layer.confirm('朋友，先注册，有个红包等着你领取！！', {
					  btn: ['注册','登陆'] // 按钮
					}, function(){
						layer.closeAll();
						zhuce();
					}, function(){
						 layer.closeAll();
						 getloginpage();
					});
				}
			});
	}
}

function getHbsm(){
	$.ajax({
		url : "lottery/getHbsm.do",
		type : "POST",
// dataType : "json",
		success : function(data) {
			layer.alert(data);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}


// 调用红包层
var getHyHb = function(obj){
  if(obj.sfhb!='undefined'&&obj.sfhb=='1'){
     // alert();
     red();
  }
};
// 弹出领取红包图像
function red() {
  layer.open({
      type: 1,
      skin: "role_btnred",
      area: '100%',
      shadeClose: true,
      btn:"领取红包",
      yes: function(index) {
// apply();
    	  findHykhxx();
          layer.close(index)
      },
      content: $(".zy_redbag")
  });
}

function findHykhxx(){
	$.ajax({
		url : "lottery/findHykhxx.do",
		type : "POST",
		dataType : "text",
		success : function(data) {
			if(data==1){
				apply()
			}else{
				layer.open({
					type : 1,
				// skin : "role_btn2",
					title : '提示',
					area : "70%",
					shadeClose : true,
					content : "<div style='padding-left:20px'>请先填写银行卡号，超过100可提现！！</br>具体步骤:<br>1:我的->修改资料->填写资料保存。<br>2:我的->银行卡信息->填写开户行、卡号后保存。</br>3:领取红包</br>4:提现(金额超过100可提现).</div>",
					btn : [ "去设置", "取消" ],
					yes : function(index) {
						getXgzl();
						layer.close(index);
					},
					btn2 : function(index) {
						layer.close(index);
						$("#hb").attr("style","display:block");
					}
				});
			}
		},
		error : function(x, h, e) {
			tips.alert("网络超时", 500);
			$("#hb").attr("style","display:block");
		}
	});
}

// 领取成功通知
function apply(){
	$.post('hyhb/getHb.do',function(data){
		if(data!=""&&data!=null){
			var  jsonData = JSON.parse(data);
			var  status = jsonData.status;
			if(status=='10'){
				var  message = jsonData.message;
				var  messageObj = JSON.parse(message);
				var  hbje = messageObj.hbje;
				var  zje = messageObj.zje;
				$("#mes").html("恭喜，您已领取了"+hbje+"元");
				getHyje();// 得到金额
				layer.open({
			        type: 1,
			        skin:"role_btnbag",
			        area: ['80%','45px'],
			        shadeClose: true,
			        content: $("#red_win")
			    });
			}else if(status=='11'){
				layer.alert(jsonData.message);
			}else{
				layer.alert("系统错误，请和管理员联系");
			}
		}
	});
}

// /////////////////////////////////////////////////////////////
function getDate(){
	var date=new Date();
	var year=date.getFullYear(); // 获取当前年份
	var mon=date.getMonth()+1; // 获取当前月份
	var da=date.getDate(); // 获取当前日
	var day=date.getDay(); // 获取当前星期几
	var h=date.getHours(); // 获取小时
	var m=date.getMinutes(); // 获取分钟
	var s=date.getSeconds(); // 获取秒
	var d=document.getElementById('Date');    
// return year+'-'+mon+'-'+da+' '+h+':'+m+':'+s;
	return year+'-'+mon+'-'+da+' '+h+':'+m;
}



function commoninit() {
	response();// rem适配
	window.onresize = function() {
		response();
	};

	// 遮罩层
// $('.loading-wrapper').fadeOut();
	closeOneTime();// 关掉定时器
	closeBoxTime();
	menu.init();
	foot.init();
	head.init();
}


// rem适配
function response() {
	var resizeEvt = 'orientationchange' in window ? 'orientationchange'
			: 'resize', recalc = function() {
		var deviceWidth = document.documentElement.clientWidth;
		document.documentElement.style.fontSize = 20 * (deviceWidth / 640)
				+ '%';
	};
	if (!document.addEventListener)
		return;
	window.addEventListener(resizeEvt, recalc, false);
	document.addEventListener('DOMContentLoaded', recalc, false);
}

/**
 * 遮罩层打开
 */
function load_open() {
	return layer.load(1, {
		shade : [ 0.4, '#fff' ]
	// 0.1透明度的白色背景
	});
}
/**
 * 遮罩层关闭
 */
function load_closeAll() {
	layer.closeAll();
}
/**
 * 遮罩层关闭--指定哪个层
 * 
 * @param index
 */
function load_close(index){
	layer.close(index);
}

$(function() {
	pushHistory();
	window.addEventListener("popstate", function(e) {
		pushHistory();
	}, false);
	function pushHistory() {
		var state = {
			title : "title",
			url : "#index"
		};
		window.history.pushState(state, "title", "#index");
	}
	
}
);

// ////////////////////////////主页js内容//////////////////////////////////////
/**
 * main 主页初始化
 */
function maininit() {
	slide();// banner触屏滑动
	mainBtnInit();// 主页按钮初始化
// // 定时器
// $(".pc_lottytime").each(function(k, v) {
// var lottery = $(this).attr("data-lottery");
// findLoteryTime(lottery);
// });
	
    $(".lottery_lose_card .ggcbutton").on("click",function(){
    	load_closeAll();
    	$(".ggcbackcolor").attr("style","display:block");
    });
	getNotice1();
// getXljcUrl();查线路的URL
	 getIsgfmm();
}

function getNotice1() {
	$.ajax({
		url : "lottery/getNotice.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			if (data.status == "4") {
				$("#noticeContent").empty();
				$("#noticeContent").append(data.message);
				$("#noticeContent span").click(function() {
					layer.alert($.trim($(this).attr("content")));
				});
			}
		},
		error : function(x, h, e) {

		}
	});
}

var secObj = new Object();

function findLoteryTime(lottery) {
	window.clearTimeout(secObj[lottery]);
	var sec = parseInt($(".time-" + lottery).attr("data-sec"));
	var c = 0;
	$.ajax({
		url : "lottery/findTime.do",
		type : "POST",
		data : {
			"lottery" : lottery
		},
		success : function(data) {
			if (typeof data != 'undefined') {
				var obj = JSON.parse(data);
				sec = parseInt(obj.CTIME);
				if (sec <= 0 || (isNaN(sec) && c < 3)) {
					// setTimeout(findLoteryTime(lottery),2000);
					c++;
				} else {
					_countTime1(sec, lottery);
				}
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});

}

function _countTime1(sec, lottery) {
	$(".time-" + lottery).attr("data-sec", sec);
	$(".time-" + lottery).html(ftime(sec));

	if (sec <= 0 || isNaN(sec)) {
		findLoteryTime(lottery);
	} else {
		sec--;
		secObj[lottery] = setTimeout("_countTime1('" + sec + "','" + lottery
				+ "')", 1000);
	}
}

function _countTime(lottery) {
	if (sec <= 0 || isNaN(sec)) {
	}
	sec--;
	$(".time-" + lottery).attr("data-sec", sec);
	$(".time-" + lottery).html(ftime(sec));

	setTimeout("_countTime('" + lottery + "')", 1000);
}
var ftime = function(t) {
	if (t <= 0)
		return "开奖...";
	var h = Math.floor(t / 3600);
	var m = Math.floor((t - 3600 * h) / 60);
	var s = t % 60;
	return (h > 0 ? (h < 10 ? "0" + h : h) + ":" : "") + (m < 10 ? "0" + m : m)
			+ ":" + (s < 10 ? "0" + s : s);
};

// banner触屏滑动
function slide() {
	if (document.getElementById('slideBox')) {
		TouchSlide({
			slideCell : "#slideBox",
			titCell : ".hd ul", // 开启自动分页 autoPage:true ，此时设置 titCell
			mainCell : ".bd ul",// 为导航元素包裹层
			effect : "leftLoop",
			interTime : 4000,
			autoPage : true,// 自动分页
			autoPlay : true
		// 自动播放
		});
	}
}

/**
 * 点击彩种,进入彩种页面
 */
function clickLettoryBtn(lottery,flag) {
	mark = lottery;
	load_closeAll();
	if(lottery =="jslhc" || lottery==55){
		fjLotteryBtn(55118,1);
	}else if(lottery =="jssc" || lottery==56){
		fjLotteryBtn(56118,1);
	}else if(lottery =="fjpk10" || lottery==57){
		fjLotteryBtn(57118,1);
	}else if(lottery =="fjxyft" || lottery==58){
		fjLotteryBtn(58118,1);
	}else if(lottery =="fjcqssc" || lottery==59){
		fjLotteryBtn(59118,1);
	}else if(lottery =="fjffc" || lottery==60){
		fjLotteryBtn(60118,1);
	}else if(lottery =="fjjsk3" || lottery==61){
		fjLotteryBtn(61118,1);
	}else if(lottery =="fjxync" || lottery==62){
		fjLotteryBtn(62118,1);
	}else if(lottery =="jssc5" || lottery==63){
		fjLotteryBtn(63118,1);
	}else if(lottery =="jslhc1" || lottery==75){
		fjLotteryBtn(75118,1);
	}else if(lottery =="jslhc3" || lottery==76){
		fjLotteryBtn(76118,1);
	}else if(lottery =="jslhc5" || lottery==77){
		fjLotteryBtn(77118,1);
	}else if(lotteryPageObj[lottery] !='' &&	lotteryPageObj[lottery] != undefined ){
		$("#subContentId").html(lotteryPageObj[lottery]);
		commoninit();// 公共部分初始化
		if (lottery == "more") {
			moreLotterinit();// 更多彩种初始化
		} else {
			$("#doc-ipt-email-1").val(cj_money);
			lotteryCommonInit();// 彩票公共初始化
			lotteryDateInit();
		}
	}else{
		$.ajax({
			url : "lottery/findOneLottery.do",
			type : "POST",
			data : {"lottery" : lottery},
			dataType : "json",
			success : function(data) {
				if(data==-1000){
					tisAlert();
					return;
				}
				if (data.message == 1) {
					if(flag==1){
						index();
						layer.alert("此彩种维护中...");
					}else{
						layer.alert("维护中...");
					}
					
				}else if(data.message == "-1"){
					sessionDia();
				} else if (data.message == 6) {
					getloginpage();
				} else {
					lotteryPageObj[lottery]= data.message;
					$("#subContentId").html(data.message);
					commoninit();// 公共部分初始化
					if (lottery == "more") {
						moreLotterinit();// 更多彩种初始化
					} else {
						$("#doc-ipt-email-1").val(cj_money);
						lotteryCommonInit();// 彩票公共初始化
						lotteryDateInit();
					}
				}
			},
			error : function(x, h, e) {
				load_closeAll();
			}
		});
	}

}

/**
 * 彩票按钮
 */
function lotteryBtn() {
// $("#J_pop_setting .kd-game").on("click", function() {
// load_closeAll();
// var lottery = $(this).find(".cptime1").attr("data-lottery");
// getintoLottery(lottery);
// });
	$("#refresh").on("click", function() {
		var index = load_open();
		lotteryDateInit();
		load_close(index);
	});
}

function getintoLottery(lottery) {
	if(lottery =="jslhc" || lottery==55){
		fjLotteryBtn(55118,1);
	}else if(lottery =="jssc" || lottery==56){
		fjLotteryBtn(56118,1);
	}else if(lottery =="fjpk10" || lottery==57){
		fjLotteryBtn(57118,1);
	}else if(lottery =="fjxyft" || lottery==58){
		fjLotteryBtn(58118,1);
	}else if(lottery =="fjcqssc" || lottery==59){
		fjLotteryBtn(59118,1);
	}else if(lottery =="fjffc" || lottery==60){
		fjLotteryBtn(60118,1);
	}else if(lottery =="fjjsk3" || lottery==61){
		fjLotteryBtn(61118,1);
	}else if(lottery =="fjxync" || lottery==62){
		fjLotteryBtn(62118,1);
	}else if(lottery =="jssc5" || lottery==63){
		fjLotteryBtn(63118,1);
	}else if(lottery =="jslhc1" || lottery==75){
		fjLotteryBtn(75118,1);
	}else if(lottery =="jslhc3" || lottery==76){
		fjLotteryBtn(76118,1);
	}else if(lottery =="jslhc5" || lottery==77){
		fjLotteryBtn(77118,1);
	}else if(lotteryPageObj[lottery] !='' &&	lotteryPageObj[lottery] != undefined ){
		$("#subContentId").html(lotteryPageObj[lottery]);
		getHyje();// 得到金额
		commoninit();// 公共部分初始化
		lotteryCommonInit();// 彩票公共初始化
		lotteryDateInit();
		$("#doc-ipt-email-1").val(cj_money);
	}else{
		var index = load_open();
		$.ajax({
			url : "lottery/findOneLottery.do",
			type : "POST",
			data : {
				"lottery" : lottery
			},
			dataType : "json",
			success : function(data) {
				load_close(index);
				if(data==-1000){
					tisAlert();
					return;
				}
				if (data.message == 1) {
					layer.alert("维护中...");
				}else if(data.message == "-1"){
					sessionDia();
				} else {
					if (data.status == "4") {
						lotteryPageObj[lottery] =data.message;
						$("#subContentId").html(data.message);
						getHyje();// 得到金额
						commoninit();// 公共部分初始化
						lotteryCommonInit();// 彩票公共初始化
						lotteryDateInit();
						$("#doc-ipt-email-1").val(cj_money);
					} else if (data.status == "6") {
						getloginpage();
					}
				}
			},
			error : function(x, h, e) {
				load_closeAll();
			}
		});
	}
}



/**
 * 主页按钮初始化
 */
function mainBtnInit() {
	var flag = true;
	// 充值
	$("#cz").on("click", function() {
		if (flag) {
			flag = false;
			$.ajax({
				url : "lottery/cztx.do",
				type : "POST",
				dataType : "json",
				success : function(data) {
					if(data==-1000){
						tisAlert();
						return;
					}
					flag = true;
					if (data.status == "6") {
						getloginpage();
					} else if (data.status == "1") {
						layer.alert(data.message);
					} else if (data.status == "4") {
						$("#subContentId").empty();
						$("#subContentId").append(data.message);
						commoninit();
						zjgl.cztx.init();
					} else if (data.status == "0") {
						alertBind();
					}else if(data.status=="5"){
						layer.open({
							type : 1,
							skin : "role_btn1",
							title : '提示',
							area : "80%",
							shadeClose : true,
							content : "<span style='font-size: 17px;margin-left: 14px;'>请先正确填写资料和银行卡后，方可充值提现</span>",
							btn : [ "马上去"],
							yes : function(index) {
								getXgzl();
								layer.close(index);
							}
						});
					}
				},
				error : function(x, h, e) {
					load_closeAll();
					flag = true;
				}
			});
		}

	});
	// 提现
	$("#tx").on("click",function() {
		var index = load_open();
				$.ajax({
					url : "lottery/cztx.do",
					type : "POST",
					dataType : "json",
					success : function(data) {
						load_close(index);
						if(data==-1000){
							tisAlert();
							return;
						}
						if (data.status == "6") {
							getloginpage();
						} else if (data.status == "1") {
							layer.alert(data.message);
						} else if (data.status == "4") {
							$("#subContentId").empty();
							$("#subContentId").append(data.message);
							commoninit();
							zjgl.cztx.init();
							$("#container1 ul li").removeClass(
									"router-link-exact-active");
							$("#container1 ul li").removeClass("active");
							$("#container1 ul li").eq(2).addClass(
									"router-link-exact-active");
							$("#container1 ul li").eq(2).addClass("active");
							$("#cz1").hide();
							$("#cz2").hide();
							$("#jyjl").hide();
							$("#tx1").show();
						} else if (data.status == "0") {
							alertBind();
						}
					},
					error : function(x, h, e) {
						load_closeAll();
					}
				});
			});
	// 登陆
	$("#login").on("click", function() {
		getloginpage();
	});
	// 注册
	$("#register").on("click", function() {
		var index1 = load_open();
		$.ajax({
			url : "lottery/registerpage.do",
			type : "POST",
			success : function(data) {
				load_close(index1);
				$("#subContentId").html(data);
				commoninit();
				registerpage.init();
			},
			error : function(x, h, e) {
				load_closeAll();
			}
		});
	});


	// 签到－－－－－幸运大转盘
	$("#zy-qd").on("click", function() {
// signin();//
		luckyTurnTable();// 幸运大转盘
	});

	// 试玩
	$("#freeTrail").on("click",function() {
		var index = load_open();
		$.ajax({url : "lottery/freeTrail.do",
				type : "POST",
				dataType : "json",
				success : function(data) {
					load_close(index);
					if (data.status == "4") {
						tips.loginAlert();
						var obj = JSON.parse(data.message);
						$("#ServerUserId").val(obj.hybm == null ? '': obj.hybm);
						$("#ServerUserName").val(obj.hymc == null ? '': obj.hymc);
						$("#ServerUserXxsx").val(obj.xxsx == null ? '': obj.xxsx);
						$("#gly").val(obj.gly==null?'':obj.gly);
						$("#right-ye").attr("login", "1");
						$("#right-ye").html('<i class="vip_img"></i><em style="text-align: left;float: left;font-style: normal; font-size: 14px;line-height: 21px;">余额<br/>5000</em>');
						// $("#register").hide();
						$("#freeTrail").hide();
						$("#cz").show();
						$("#tx").show();
						if ($("#ServerUserId").val() != '') {
							clientinit();
						}
					} else {
						layer.alert("试玩失败");
					}
				},
				error : function(x, h, e) {
					load_closeAll();
				}
			});
});

	// 客服
	$("#kf").on("click", function() {
// getKf();
		layer.open({
	        type: 1,
	        title: '客服',
	        skin : "role_btn20",
// area:['80%', '35%'],
	        area:'auto',
	        shadeClose: true,
	        content: $("#kfbox")
	    });
	});

	$(".swiper-slide").on("click", function() {
		var isevent = $(this).attr("isevent");
		if (isevent == 1) {
			getYhhd();
		}else{
			var url = $(this).attr("tzurl");
			if(url!=''&& url!=undefined && url!=1){
				 window.open(url,'_blank');
			}
		}
	});
}

// 查询会员金额
function getHyje() {
	$.ajax({
		url : "lottery/getHyje.do",
		type : "POST",
		timeout : 10000,
		dataType : "json",
		success : function(data) {
			if(data==-1){
				layer.alert("长时间未操作，请重新登陆");
				getloginpage();
			}else{
				$("#zhzje").html(data);
				$(".zhzje").html(data);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
			layer.alert("请求错误，请重新登陆");
			getloginpage();
		},
		complete: function (XMLHttpRequest, status) { // 当请求完成时调用函数
	        if (status == 'timeout') {// status ==
										// 'timeout'意为超时,status的可能取值：success,notmodified,nocontent,error,timeout,abort,parsererror
	        	 getHyje();
	    	}
		}
	});
}

// 各种提示信息
var tips = {
	// 登录提示
	loginAlert : function() {
		layer.open({
			type : 1,
			skin : "role_btn9",
			area : '90%',
			shadeClose : true,
			content : $("#zysw_box"),
			time : 500
		});
	},
	// 签到提示
	signinAlert : function(message) {
		$("#signinAlert span").html(message);
		layer.open({
			type : 1,
			skin : "role_btn9",
			area : '90%',
			shadeClose : true,
			content : $("#signinAlert"),
			time : 500
		});
	},
	// 提示注册
	registerAlert : function() {
		layer.open({
			type : 1,
			skin : "role_btn9",
			area : '90%',
			shadeClose : true,
			content : $("#registerAlert"),
			time : 500
		});
	},
	alert : function(message, time) {
		if (time == undefined) {
			time = 2000;
		}
		$("#content").html(message);
		layer.open({
			type : 1,
			skin : "role_btn9",
			area : '90%',
			shadeClose : true,
			content : $("#alert"),
			time : time
		});
	},
	alertNoShade : function(message) {
		$("#xxp").text(message);
		layer.open({
			type : 1,
			skin : 'role_btn16', // 样式类名
			title : '',
			area : 'auto',
			closeBtn : 0, // 不显示关闭按钮
			time : 2000,
			shade : 0,
			offset : '50px',
			content : $("#xx")
		});
	},
	alertNoShadeNoTime : function(message) {
		$("#xxp").text(message);
		layer.open({
			type : 1,
			skin : 'role_btn16', // 样式类名
			title : '',
			area : 'auto',
			closeBtn : 1, // 不显示关闭按钮
			shade : 0,
			offset : '50px',
			content : $("#xx")
		});
	}
};

/*
 * 登录页
 */
var loginpage = {
	init : function() {
		/*
		 * 登录
		 */
		$("#login").on(
				"click",
				function() {
					if (!loginpage.validation()) {
						return;
					}
					var index1 = load_open();
					if(window.localStorage){
			            var storage=window.localStorage;
			            storage.setItem("username",$.trim($("#username").val()));
			            storage.setItem("password", $.trim($("#password").val()));
			        }
					var encrypt = new JSEncrypt();
					encrypt.setPublicKey(PUBLIC_KEY);
					$.ajax({
						url : "lottery/login.do",
						data : {
							"hydlmc" : $.trim($("#username").val()),
							"hymm" : encrypt.encrypt($.trim($("#password").val()))
						},
						type : "POST",
						dataType : "json",
						success : function(data) {
							load_close(index1);
							if (data.status == "4") {
								// alert(data.message);
								// alert();
								var obj = JSON.parse(data.message);
								$("#ServerUserId").val(
										obj.hybm == null ? '' : obj.hybm);
								$("#ServerUserName").val(
										obj.hymc == null ? '' : obj.hymc);
								$("#ServerUserXxsx").val(
										obj.xxsx == null ? '' : obj.xxsx);
								$("#gly").val(obj.gly==null?'':obj.gly);
								
								if (mark == 0) {// 首页
									index(1);
								} else if (mark == 2) {// 在线充值
									getCztxInFooter();
								} else if (mark == 3) {// 我的地盘
									wddp();
								} else if(mark == 4){// 在线客服
// getZxkf();
									index(1);
								} else if(mark == 5 ){// 优惠活动
									getYhhd();
								}else if (mark == 31) {// 代理推广
									getDltg();
								} else if (mark == 32) {// 下注记录
									getXzjl();
								} else if (mark == 33) {// 消息记录
									getXxjl();
								} else {
									clickLettoryBtn(mark,1);
// index();
								}
							// getHbInit(obj);
								if ($("#ServerUserId").val() != '') {
									clientinit();
								}
							} else if (data.status == "1") {
								layer.alert(data.message);

							}
						},
						error : function(x, h, e) {
							load_closeAll();
						}
					});
				});

		/*
		 * 马上注册
		 */
		$("#register").on("click", function() {
			var index = load_open();
			$.ajax({
				url : "lottery/registerpage.do",
				type : "POST",
				success : function(data) {
					load_close(index);
					$("#subContentId").html(data);
					commoninit();
					registerpage.init();
				},
				error : function(x, h, e) {
					load_closeAll();
				}
			});
		});

		/*
		 * 免费试玩
		 */
		$("#freeTrail").on("click",function() {
			var index1 = load_open();
					$.ajax({
						url : "lottery/freeTrailPage.do",
						type : "POST",
						dataType : "json",
						success : function(data) {
							load_close(index1);
							var obj = JSON.parse(data.message);
							if (data.status == "4") {
								$("#ServerUserId").val(
										obj.hybm == null ? '' : obj.hybm);
								$("#ServerUserName").val(
										obj.hymc == null ? '' : obj.hymc);
								$("#ServerUserXxsx").val(
										obj.xxsx == null ? '' : obj.xxsx);
								$("#gly").val(obj.gly == null ? '' : obj.gly);
								if (mark == 0) {// 首页
									index();
								} else if (mark == 2) {// 在线充值
// getCztxInFooter();
									index();
								} else if (mark == 3) {// 我的地盘
// wddp();
									index();
								}else if(mark == 4){// 在线客服
									getZxkf();
								} else if(mark == 5 ){// 优惠活动
									getYhhd();
								} else if (mark == 31) {// 代理推广
// getDltg();
									index();
								} else if (mark == 32) {// 下注记录
									getXzjl();
								} else if (mark == 33) {// 消息记录
									getXxjl();
								} else {
									clickLettoryBtn(mark,1);
								}
								tips.loginAlert();
								if ($("#ServerUserId").val() != '') {
									clientinit();
								}
							}
						},
						error : function(x, h, e) {
							load_closeAll();
						}
					});
				});

		/*
		 * 找回密码
		 */
		$("#wjmm").on("click", function() {
			getWjmm();
		});

		$("footer li").removeClass("active");
	},
	validation : function() {
		if ($("#username").val() == "") {
			tips.alert("用户名不能为空");
			return false;
		}
		if ($("#password").val() == "") {
			tips.alert("密码不能为空");
			return false;
		}
		return true;
	},
	// 忘记密码
	wjmm : {
		init : function() {
			$("#back, .kd-button.hollow").on("click", function() {
				getloginpage();
			});

			/*
			 * 重新加载验证码
			 */
			$("#checkcodeImage").on(
					"click",
					function() {
						$(this).attr("src",
								"zhmm/getCheckcodeImage.do?" + Math.random());
					});

			$("#next1")
					.on(
							"click",
							function() {
								if (loginpage.wjmm.validation1()) {
									$
											.ajax({
												url : "lottery/wjmm1.do",
												type : "POST",
												data : {
													hydlmc : $("#username")
															.val(),
													checkcode : $("#checkcode")
															.val()
												},
												dataType : "json",
												success : function(data) {
													if (data.status == "4") {
														var obj = JSON
																.parse(data.message);
														if (obj.aqwt1 != undefined) {
															$("#aqwt")
																	.append(
																			'<label class="kd-field-title" style="margin-bottom:5px;">'
																					+ obj.aqwt1
																					+ '</label>'
																					+ '<label class="kd-field-title">答案</label>'
																					+ '<div class="kd-textinput text"><input type="text" id="aqwt1da" placeholder="请输入您设定的安全问题答案"></div>');
															loginpage.wjmm.aqwt = 1;
														} else {
															$("#aqwt")
																	.append(
																			'<label class="kd-field-title" style="font-weight: 700; color: red;font-size:14px;">您没有设置安全问题，无法通过安全问题找回密码！</label>');
															$("#next2").hide();
															loginpage.wjmm.aqwt = 0;
														}
														if (obj.email == undefined) {
															$("#email")
																	.append(
																			'<label class="kd-field-title" style="font-weight: 700; color: red;font-size:14px;">您没有设置邮箱，无法通过邮箱找回密码！</label>');
															loginpage.wjmm.email = 0;
														} else {
															loginpage.wjmm.email = 1;
														}
														$("#checkcodeImage2")
																.attr(
																		"src",
																		"zhmm/getCheckcodeImage.do?"
																				+ Math
																						.random());
														$("#step1").hide();
														$("#step2").show();
													} else {
														tips.alert(data.message);
													}
												},
												error : function(x, h, e) {
													load_closeAll();
												}
											});
								}
							});

			$("#next2").on(
					"click",
					function() {
						if (loginpage.wjmm.validation2()) {
							$.ajax({
								url : "lottery/wjmm2.do",
								type : "POST",
								data : {
									type : $("#type").val(),
									aqwt1da : $("#aqwt1da").val(),
									checkcode : $("#checkcode2").val()
								},
								dataType : "json",
								success : function(data) {
									if (data.status == "4") {
										$("#checkcodeImage3").attr(
												"src",
												"zhmm/getCheckcodeImage.do?"
														+ Math.random());
										$("#step2").hide();
										$("#step3").show();
										if ($("#type").val() == "2") {
											$("#emailcode").show();
										} else {
											$("#emailcode").hide();
										}
										tips.alert(data.message);
									} else if (data.status == "6") {
										getloginpage();
										tips.alert(data.message);
									} else {
										tips.alert(data.message);
									}
								},
								error : function(x, h, e) {
									load_closeAll();
								}
							});
						}
					});

			$("#checkcodeImage2").on(
					"click",
					function() {
						$(this).attr("src",
								"zhmm/getCheckcodeImage.do?" + Math.random());
					});

			$("#type").on("change", function() {
				$("#aqwt").toggle();
				$("#email").toggle();
				if ($(this).val() == "1") {
					if (loginpage.wjmm.aqwt == 0) {
						$("#next2").hide();
					} else {
						$("#next2").show();
					}
				} else {
					if (loginpage.wjmm.email == 0) {
						$("#next2").hide();
					} else {
						$("#next2").show();
					}
				}
			});

			$("#next3").on("click", function() {
				if (loginpage.wjmm.validation3()) {
					$.ajax({
						url : "lottery/wjmm3.do",
						type : "POST",
						data : {
							np1 : $("#np1").val(),
							np2 : $("#np2").val(),
							type : $("#type").val(),
							emailcode : $("#emailcode").val(),
							checkcode : $("#checkcode3").val()
						},
						dataType : "json",
						success : function(data) {
							if (data.status == "4") {
								if (mark == 0) {// 首页
									index(1);
								} else if (mark == 2) {// 在线充值
									getCztxInFooter();
								} else if (mark == 3) {// 我的地盘
									wddp();
								} else if(mark == 4){// 在线客服
									getZxkf();
								} else if(mark == 5 ){// 优惠活动
									getYhhd();
								}else if (mark == 31) {// 代理推广
									getDltg();
								} else if (mark == 32) {// 下注记录
									getXzjl();
								} else if (mark == 33) {// 消息记录
									getXxjl();
								} else {
									clickLettoryBtn(mark,1);
								}
							} else if (data.status == "6") {
								getloginpage();
								tips.alert(data.message);
							} else {
								tips.alert(data.message);
							}
						},
						error : function(x, h, e) {
							load_closeAll();
						}
					});
				}
			});

			$("#checkcodeImage3").on(
					"click",
					function() {
						$(this).attr("src",
								"zhmm/getCheckcodeImage.do?" + Math.random());
					});

			$("footer li").removeClass("active");
		},
		validation1 : function() {
			if ($("#username").val().trim() == "") {
				tips.alert("账号不能为空");
				return false;
			}
			if ($("#checkcode").val().trim() == "") {
				tips.alert("验证码不能为空")
				return false;
			}
			return true;
		},
		validation2 : function() {
			if ($("#checkcode2").val().trim() == "") {
				tips.alert("验证码不能为空")
				return false;
			}
			return true;
		},
		validation3 : function() {
			var reg = /^\w{6,20}$/;
			if (!reg.test($("#np1").val())) {
				tips.alert("密码格式不正确");
				return false;
			}
			if ($("#np1").val() != $("#np2").val()) {
				tips.alert("两次密码不一致");
				return false;
			}
			if ($("#checkcode3").val().trim() == "") {
				tips.alert("验证码不能为空")
				return false;
			}
			return true;
		},
		aqwt : 1,
		email : 1
	}
};

/*
 * 注册页
 */
var registerpage = {
	init : function() {
		/*
		 * 开户条约
		 */
		$("#readRule").on("click", function() {
			layer.open({
				type : 1,
				skin : "role_btn5",
				title : '规则条例及隐私声明',
				area : '90%',
				shadeClose : true,
				content : $("#rule")
			});
		});

		/*
		 * 马上注册
		 */
		$("#register").on("click",function() {
					if (!$("#checkboxFiveInput1").prop("checked")) {
						tips.alert("请勾选开户条约");
						return;
					}
					if (!registerpage.validation()) {
						return;
					}
					var index1 = load_open();
					var encrypt = new JSEncrypt();
					encrypt.setPublicKey(PUBLIC_KEY);
					$.ajax({
						url : "lottery/register.do",
						data : {
							"hydlmc" : $("#hydlmc").val(),
							"hymm" : encrypt.encrypt($("#hymm").val()),
							"qq" : $("#qq").val()
						},
						type : "POST",
						dataType : "json",
						success : function(data) {
							load_close(index1);
							if (data.status == "4") {
								var obj = JSON.parse(data.message);
								$("#ServerUserId").val(
										obj.hybm == null ? '' : obj.hybm);
								$("#ServerUserName").val(
										obj.hymc == null ? '' : obj.hymc);
								
// $("#sfhb").val(
// obj.sfhb == null&&obj.sfhb!=undefined ? '' : obj.sfhb);
								// alert(obj.sfhb);
								if (mark == 0) {// 首页
									index();
								} else if (mark == 2) {// 在线充值
									getCztxInFooter();
								} else if (mark == 3) {// 我的地盘
									wddp();
								} else if(mark == 4){// 在线客服
									getZxkf();
								} else if(mark == 5 ){// 优惠活动
									getYhhd();
								}else if (mark == 31) {// 代理推广
									getDltg();
								} else if (mark == 32) {// 下注记录
									getXzjl();
								} else if (mark == 33) {// 消息记录
									getXxjl();
								} else {
									clickLettoryBtn(mark,1);
								}
								// 弹出红包信息
								getHbInit(obj);
								tips.loginAlert();
								if ($("#ServerUserId").val() != '') {
									clientinit();
								}
							} else if (data.status == "1") {
								load_close(index1);
								layer.alert(data.message);
							}
						},
						error : function(x, h, e) {
							load_closeAll();
						}
					});
				});

		/*
		 * 立即登录
		 */
		$("#login").on("click", function() {
			getloginpage();
		});

		$("footer li").removeClass("active");
	},
	validation : function() {
		var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;
		if (!reg.test($("#hydlmc").val())) {
			tips.alert("用户名格式不正确");
			return false;
		}
		reg = /^\w{6,20}$/;
		if (!reg.test($("#hymm").val())) {
			tips.alert("密码格式不正确");
			return false;
		}
		if ($("#hymm").val() != $("#hymm1").val()) {
			tips.alert("两次密码不一致");
			return false;
		}
		reg = /^\d{5,11}$/;
		if (!reg.test($("#qq").val())) {
			tips.alert("QQ格式不正确");
			return false;
		}
		return true;
	}
};

/*
 * 侧边菜单
 */
var menu = {
	init : function() {
		$("#menu ul li").on("click", function() {
			$("#menu ul li").removeClass("menu_cur");
			$(this).addClass("menu_cur");
		});

		$("#index").on("click", function() {
			mark = 0;
			index();
		});

		$("#yhhd").on("click", function() {
			getYhhd();
		});

		$("#dltg1").on("click", function() {
			mark = 31;
			getDltg();
		});

		$("#xzjl1").on("click", function() {
			mark = 32;
			getXzjl();
		});
		/**
		 * 签到
		 */
// $("#signin").on("click", function() {
// luckyTurnTable();//幸运大转盘
// });

		$("#xtxx").on("click", function() {
			mark = 33;
			getXxzx();
		});
	},
	yhhd : {
		init : function() {
			$("#us_panel").find("li").removeClass("active");
			$("#us_panel").find("li").eq(3).addClass("active");
			$("#back").on("click", function() {
				if (mark == 0) {// 首页
					index();
				} else if (mark == 2) {// 在线充值
					getCztxInFooter();
				} else if (mark == 3) {// 我的地盘
					wddp();
				} else if(mark == 4){// 在线客服
					getZxkf();
				} else if(mark == 5 ){// 优惠活动
					getYhhd();
				}else if (mark == 31) {// 代理推广
					getDltg();
				} else if (mark == 32) {// 下注记录
					getXzjl();
				} else if (mark == 33) {// 消息记录
					getXxjl();
				} else {
					clickLettoryBtn(mark);
				}
			});
		}
	}
};

/*
 * 底部菜单
 */
var foot = {
	init : function() {
		$("footer ul li").on("click", function() {
			$("footer ul li").removeClass("active");
			$(this).addClass("active");
			if (typeof (member.dltg.clipboard.destroy) == 'function') {
				member.dltg.clipboard.destroy();
			}
			if (typeof (clipboard1) != 'undefined') {
				clipboard1.destroy();
			}
			if (typeof (clipboard1_xm) != 'undefined') {
				clipboard1_xm.destroy();
			}
			if (typeof (clipboard1_zh) != 'undefined') {
				clipboard1_zh.destroy();
			}
			if (typeof (clipboard2) != 'undefined') {
				clipboard2.destroy();
			}
			if (typeof (clipboard2_xm) != 'undefined') {
				clipboard2_xm.destroy();
			}
			if (typeof (clipboard2_zh) != 'undefined') {
				clipboard2_zh.destroy();
			}
			if (typeof (member.cztx.clipboard_acc) != 'undefined') {
				member.cztx.clipboard_acc.destroy();
			}
			var p = $(this).find("p").html();
			if (p == "首页") {
				mark = 0;
				index();
			}else if(p=="客服"){
				mark = 4;
				getZxkf();
			} else if(p=="活动"){
				mark = 0;
				getYhhd();
			} else if (p == "游戏大厅") {
				clickLettoryBtn("more");
			} else if (p == "充值") {
				mark = 2;
				getCztxInFooter();
			} else if (p == "我的") {
				mark = 0;
				wddp();
			}else if(p == "线路检测"){
				mark = 0;
				xljc();
			}
		});
	}
};

/*
 * 我的地盘
 */
var member = {
	// 初始化
	init : function() {
		$("#dltg").on("click", function() {
			getDltg();
		});

		$("#cztx").on("click", function() {
			getCztx();
		});
		
		$("#tx").on("click", function() {
			getTx();
		});

		$("#xzyx").on("click", function() {
			clickLettoryBtn("more");
		});

		$("#xxzx").on("click", function() {
			getXxzx();
		});

		$("#xgzl").on("click", function() {
			getXgzl();
		});

		$("#yhkxx").on("click", function() {
			getYhkxx();
		});

		$("#kjjl").on("click", function() {
			layer.open({
				type : 1,
				skin : "role_btn",
				title : "选择彩种",
				area : [ '100%', '100%' ],
				shadeClose : true,
				content : $("#J_pop_setting1")
			});
		});

		$("#jrzd").on("click", function() {
			getJrzd();
		});

		$("#xzjl").on("click", function() {
			getXzjl();
		});

		$("#zhls").on("click", function() {
			getZhls();
		});

		$("#gryk1").on("click", function() {
			getGryk1();
		});

		$("#dlyk").on("click", function() {
			getDlyk();
		});

		$("#logout").on("click", function() {
			logout();
		});

		// $("#xjtz").on("click", function(){
		// load_open();
		// getXjtz();
		// });
	},
	// 代理推广
	dltg : {
		init : function() {
			member.dltg.clipboard = new Clipboard("#copy");
			member.dltg.clipboard.on("success", function(element) {// 复制成功的回调
				load_closeAll();
				tips.alert("已复制到剪切板");
			});
			member.dltg.clipboard.on("error", function(element) {// 复制失败的回调
				tips.alert("请长按链接手动复制");
			});

			$('#qrcode').qrcode({
				width : 200,
				height : 200,
				correctLevel : 0,
				text : $("#link").val()
			});
			var dataImg = $("canvas")[0].toDataURL('image/png');
			$("#qrcode").empty();
			$("#imgdiv").css("display", "block");
			$("#img").prop("src", dataImg);
			$("#save").prop("href", dataImg);

			$("#back").on("click", function() {
				member.dltg.clipboard.destroy();
				wddp();
			});

			$("#tgzx").on("click", function() {
				member.dltg.clipboard.destroy();
				var index = load_open();
				$.ajax({
					url : "lottery/tgzx.do",
					type : "POST",
					dataType : "json",
					success : function(data) {
						load_close(index);
						if(data==-1000){
							tisAlert();
							return;
						}
						if (data.status == "6") {
							getloginpage();
						} else if (data.status == "1") {
							tips.alert(data.message);
						} else {
							$("#subContentId").empty();
							$("#subContentId").append(data.message);
							commoninit();
							member.dltg.tgzx.init();
						}
					},
					error : function(x, h, e) {
						load_closeAll();
					}
				});
			});
		},
		tgzx : {
			init : function() {
				$("#back, .continue").on("click", function() {
					getDltg();
				});
			}
		},
		clipboard : {}
	},
	// 充值/提现
	cztx : {
		init : function(cpzl,wfbm1,fjmoney) {
			member.cztx.flag = cpzl;
			
			member.cztx.clipboard_acc = new Clipboard(".copy1");
			member.cztx.clipboard_acc.on("success", function(element) {// 复制成功的回调
				load_closeAll();
				tips.alert("已复制到剪切板");
			});
			member.cztx.clipboard_acc.on("error", function(element) {// 复制失败的回调
				tips.alert("请长按链接手动复制");
			});

			$("#back").on("click", function() {
				if (typeof (clipboard1) != 'undefined') {
					clipboard1.destroy();
				}
				if (typeof (clipboard1_xm) != 'undefined') {
					clipboard1_xm.destroy();
				}
				if (typeof (clipboard1_zh) != 'undefined') {
					clipboard1_zh.destroy();
				}
				if (typeof (clipboard2) != 'undefined') {
					clipboard2.destroy();
				}
				if (typeof (clipboard2_xm) != 'undefined') {
					clipboard2_xm.destroy();
				}
				if (typeof (clipboard2_zh) != 'undefined') {
					clipboard2_zh.destroy();
				}
				if (typeof (member.cztx.clipboard_acc) != 'undefined') {
					member.cztx.clipboard_acc.destroy();
				}
				
				if (cpzl == undefined) {
					wddp();
				}else if((cpzl==51 || cpzl==52 || cpzl==53 || cpzl==54 || cpzl==55 || cpzl ==56 ||
						cpzl==57 || cpzl==58 || cpzl==59 ||cpzl==60 || cpzl==61 || cpzl==62 || cpzl==75 || cpzl==76 || cpzl==77)&& wfbm1!=undefined){
					fjLotteryBtn(wfbm1,fjmoney);
				} else {
					getintoLottery(cpzl);
				}
			});

			$("#container1 ul.nostyle.account-sub-nav.account-sub1.kd-row-middle li").on(
					"click",
					function() {
						var index = $(this).index();
						if (index == 0) {
							$("#container1 ul li").removeClass(
									"router-link-exact-active");
							$("#container1 ul li").removeClass("active");
							$("#container1 ul li").eq(0).addClass(
									"router-link-exact-active");
							$("#container1 ul li").eq(0).addClass("active");
							$("#tx1").hide();
							$("#jyjl").hide();
							$("#cz2").hide();
							$("#cz1").show();
						} else if (index == 1) {
							$("#container1 ul li").removeClass(
									"router-link-exact-active");
							$("#container1 ul li").removeClass("active");
							$("#container1 ul li").eq(1).addClass(
									"router-link-exact-active");
							$("#container1 ul li").eq(1).addClass("active");
							$("#cz1").hide();
							$("#jyjl").hide();
							$("#tx1").hide();
							$("#cz2").show();
						}  else {
							getJyjl(1);
						}
					});
			$("#container1 ul.nostyle.account-sub-nav.account-sub2.kd-row-middle li").on(
					"click",
					function() {
						var index = $(this).index();
						if (index == 0) {
							$("#container1 ul li").removeClass(
									"router-link-exact-active");
							$("#container1 ul li").removeClass("active");
							$("#container1 ul li").eq(0).addClass(
									"router-link-exact-active");
							$("#container1 ul li").eq(0).addClass("active");
							$("#cz1").hide();
							$("#cz2").hide();
							$("#jyjl").hide();
							$("#tx1").show();
						} else {
							getJyjl(2);
						}
					});

			// $("div.type-title.kd-container.Collapsing").on("click",
			// function(){
			// if($(this).hasClass("current")){
			// $(this).removeClass("current");
			// $(this).next().hide();
			// }else{
			// $(this).addClass("current");
			// $("div.type-body.coll_body").hide();
			// $(this).next().show();
			// }
			// });
			$("div.Collapsing.topup_czbs").on("click", function() {
				if ($(this).hasClass("current")) {
					$(this).removeClass("current");
					$(this).next().hide();
					$(".kd-form .topup_czbs").removeClass("topup_top");
				} else {
					$(this).addClass("current");
					$("div.type-body.coll_body").hide();
					$(this).next().show();
					$(this).addClass("topup_top");
				}
			});

			$("#tx").on(
					"click",
					function() {
						if (!member.cztx.validation()) {
							return;
						}
						var index = load_open();
						$.ajax({
							url : "lottery/getPoundage.do",
							data : {
								"txje" : $("#txje").val()
							},
							type : 'post',
							cache : false,
							dataType : 'text',
							success : function(data) {
								var money = parseFloat(data);
								load_close(index);
								if ((money != 0 && confirm("将收取" + data
										+ "元手续费，确定继续提现操作？"))
										|| money == 0) {
									var index1 = load_open();
									var encrypt = new JSEncrypt();
									encrypt.setPublicKey(PUBLIC_KEY);
									$.ajax({
										url : "lottery/tx.do",
										data : {
											"txje" : $("#txje").val(),
											"hyzfmm" :  encrypt.encrypt($("#hyzfmm").val()),
											"yhkxxsn" : $("#yhkxxsn").val()
										},
										type : 'post',
										cache : false,
										dataType : 'json',
										success : function(data) {
											load_close(index1);
											if(data==-1000){
												tisAlert();
												return;
											}
											if (data.status == "6") {
												getloginpage();
											} else if (data.status == "4") {
												layer.alert(data.message);
												wddp();
												// 发送提现信息到后台
												// sendMessageWithType("tx");
											} else {
												tips.alert(data.message);
											}
										},
										error : function() {
											load_closeAll();
										}
									});
								}
							},
							error : function() {
								load_closeAll();
							}
						});
					});
		},
		validation : function() {
			var reg = /^\d{1,9}$/;
			if (!reg.test($("#txje").val())) {
				tips.alert("提现金额必须为整数");
				return false;
			}
			reg = /^\w{6,20}$/;
			if (!reg.test($("#hyzfmm").val())) {
				tips.alert("支付密码格式错误");
				return false;
			}
			return true;
		},
		// 交易记录
		jyjl : {
			init : function() {
				$("#back").on("click", function() {
					getCztx(member.cztx.flag);
				});

				$("#container1 ul li")
						.on(
								"click",
								function() {
									var index = $(this).index();
									$("#container1 ul li").removeClass(
											"router-link-exact-active");
									$("#container1 ul li")
											.removeClass("active");
									$("#container1 ul li").eq(index).addClass(
											"router-link-exact-active");
									$("#container1 ul li").eq(index).addClass(
											"active");
									$(".czjy_jl").hide();
									$(".czjy_jl").eq(index).show();
								});

				$("#filter_czjl").on(
						"click",
						function() {
							layer.open({
								type : 1,
								skin : "role_btn7",
								title : '过滤',
								area : '90%',
								btn : "确定",
								shadeClose : true,
								content : $("#cz"),
								yes : function(index) {
									layer.close(index);
									var qssj = $("#qssj").val();
									var jzsj = $("#jzsj").val();
									var czlx = $("#czlx").val();
									var czzt = $("#czzt").val();
									getCzjl(member.cztx.jyjl.czjl.pagesize, 1,
											qssj, jzsj, czlx, czzt);
								}
							});
						});

				$("#filter_txjl").on(
						"click",
						function() {
							layer.open({
								type : 1,
								skin : "role_btn7",
								title : '过滤',
								area : '90%',
								btn : "确定",
								shadeClose : true,
								content : $("#tx"),
								yes : function(index) {
									layer.close(index);
									var qssj = $("#qssj_txjl").val();
									var jzsj = $("#jzsj_txjl").val();
									var txzt = $("#txzt").val();
									getTxjl(member.cztx.jyjl.txjl.pagesize, 1,
											qssj, jzsj, txzt);
								}
							});
						});
			},
			czjl : {
				pagesize : 5,
				init : function() {
					$("#first_czjl").on(
							"click",
							function() {
								var pagenum = 1;
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var czlx = $("#czlx").val();
								var czzt = $("#czzt").val();
								getCzjl(member.cztx.jyjl.czjl.pagesize,
										pagenum, qssj, jzsj, czlx, czzt);
							});

					$("#last_czjl").on(
							"click",
							function() {
								var pagenum = tn_czjl == 0 ? 1 : tn_czjl;
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var czlx = $("#czlx").val();
								var czzt = $("#czzt").val();
								getCzjl(member.cztx.jyjl.czjl.pagesize,
										pagenum, qssj, jzsj, czlx, czzt);
							});

					$("#prev_czjl").on(
							"click",
							function() {
								var pagenum;
								if (tn_czjl == 0 || tn_czjl == 1) {
									pagenum = 1;
								} else {
									if (pn_czjl > 1) {
										pagenum = pn_czjl - 1;
									} else {
										pagenum = 1;
									}

								}
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var czlx = $("#czlx").val();
								var czzt = $("#czzt").val();
								getCzjl(member.cztx.jyjl.czjl.pagesize,
										pagenum, qssj, jzsj, czlx, czzt);
							});

					$("#next_czjl").on(
							"click",
							function() {
								var pagenum;
								if (tn_czjl == 0 || tn_czjl == 1) {
									pagenum = 1;
								} else {
									if (pn_czjl < tn_czjl) {
										pagenum = pn_czjl + 1;
									} else {
										pagenum = pn_czjl;
									}

								}
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var czlx = $("#czlx").val();
								var czzt = $("#czzt").val();
								getCzjl(member.cztx.jyjl.czjl.pagesize,
										pagenum, qssj, jzsj, czlx, czzt);
							});
				}
			},
			txjl : {
				pagesize : 5,
				init : function() {
					$("#first_txjl").on(
							"click",
							function() {
								var pagenum = 1;
								var qssj = $("#qssj_txjl").val();
								var jzsj = $("#jzsj_txjl").val();
								var txzt = $("#txzt").val();
								getTxjl(member.cztx.jyjl.txjl.pagesize,
										pagenum, qssj, jzsj, txzt);
							});

					$("#last_txjl").on(
							"click",
							function() {
								var pagenum = tn_txjl == 0 ? 1 : tn_txjl;
								var qssj = $("#qssj_txjl").val();
								var jzsj = $("#jzsj_txjl").val();
								var txzt = $("#txzt").val();
								getTxjl(member.cztx.jyjl.txjl.pagesize,
										pagenum, qssj, jzsj, txzt);
							});

					$("#prev_txjl").on(
							"click",
							function() {
								var pagenum;
								if (tn_txjl == 0 || tn_txjl == 1) {
									pagenum = 1;
								} else {
									if (pn_txjl > 1) {
										pagenum = pn_txjl - 1;
									} else {
										pagenum = 1;
									}

								}
								var qssj = $("#qssj_txjl").val();
								var jzsj = $("#jzsj_txjl").val();
								var txzt = $("#txzt").val();
								getTxjl(member.cztx.jyjl.txjl.pagesize,
										pagenum, qssj, jzsj, txzt);
							});

					$("#next_txjl").on(
							"click",
							function() {
								var pagenum;
								if (tn_txjl == 0 || tn_txjl == 1) {
									pagenum = 1;
								} else {
									if (pn_txjl < tn_txjl) {
										pagenum = pn_txjl + 1;
									} else {
										pagenum = pn_txjl;
									}

								}
								var qssj = $("#qssj_txjl").val();
								var jzsj = $("#jzsj_txjl").val();
								var txzt = $("#txzt").val();
								getTxjl(member.cztx.jyjl.txjl.pagesize,
										pagenum, qssj, jzsj, txzt);
							});
				}
			}
		},
		flag : 1
	},
	// 消息中心
	xxzx : {
		init : function() {
			$("#back").on("click", function() {
				wddp();
			});

			$("#xxzt li").on("click", function() {
				var pagenum = 1;
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var xxlx = $("#xxlx").val();
				var xxzt = $(this).attr("xxzt");
				getXxzx(member.xxzx.pagesize, pagenum, qssj, jzsj, xxlx, xxzt);
			});

			$(".cop").on("click", function() {
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var xxlx = $("#xxlx").val();
				var xxzt = $(this).attr("xxzt");
				var sn = $(this).attr("sn");
				if (xxzt == "0") {
					markXx(qssj, jzsj, xxlx, sn);
				} else {
					delXx(qssj, jzsj, xxlx, sn);
				}
			});

			$("#markAll").on("click", function() {
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var xxlx = $("#xxlx").val();
				var s = $(".cop");
				var sn = "";
				for ( var i = 0; i < s.length; i++) {
					if (i == 0) {
						sn += $(s[i]).attr("sn");
					} else {
						sn += "," + $(s[i]).attr("sn");
					}
				}
				markAll(qssj, jzsj, xxlx, sn);
			});

			$("#delAll").on("click", function() {
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var xxlx = $("#xxlx").val();
				var s = $(".cop");
				var sn = "";
				for ( var i = 0; i < s.length; i++) {
					if (i == 0) {
						sn += $(s[i]).attr("sn");
					} else {
						sn += "," + $(s[i]).attr("sn");
					}
				}
				delAll(qssj, jzsj, xxlx, sn);
			});

			$("#first").on("click", function() {
				var pagenum = 1;
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var xxlx = $("#xxlx").val();
				var xxzt = $("#xxzt li.active").attr("xxzt");
				getXxzx(member.xxzx.pagesize, pagenum, qssj, jzsj, xxlx, xxzt);
			});

			$("#last").on("click", function() {
				var pagenum = tn == 0 ? 1 : tn;
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var xxlx = $("#xxlx").val();
				var xxzt = $("#xxzt li.active").attr("xxzt");
				getXxzx(member.xxzx.pagesize, pagenum, qssj, jzsj, xxlx, xxzt);
			});

			$("#prev").on("click", function() {
				var pagenum;
				if (tn == 0 || tn == 1) {
					pagenum = 1;
				} else {
					if (pn > 1) {
						pagenum = pn - 1;
					} else {
						pagenum = 1;
					}

				}
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var xxlx = $("#xxlx").val();
				var xxzt = $("#xxzt li.active").attr("xxzt");
				getXxzx(member.xxzx.pagesize, pagenum, qssj, jzsj, xxlx, xxzt);
			});

			$("#next").on("click", function() {
				var pagenum;
				if (tn == 0 || tn == 1) {
					pagenum = 1;
				} else {
					if (pn < tn) {
						pagenum = pn + 1;
					} else {
						pagenum = pn;
					}

				}
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var xxlx = $("#xxlx").val();
				var xxzt = $("#xxzt li.active").attr("xxzt");
				getXxzx(member.xxzx.pagesize, pagenum, qssj, jzsj, xxlx, xxzt);
			});

			$("#filter").on(
					"click",
					function() {
						layer.open({
							type : 1,
							skin : "role_btn7",
							title : '过滤',
							area : '90%',
							btn : "确定",
							shadeClose : true,
							content : $(".promptbox-wrapper"),
							yes : function(index) {
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var xxlx = $("#xxlx").val();
								var xxzt = $("#xxzt li.active").attr("xxzt");
								layer.close(index);
								getXxzx(member.xxzx.pagesize, 1, qssj, jzsj,
										xxlx, xxzt);
							}
						});
					});
		},
		pagesize : 5
	},
	// 修改资料
	xgzl : {
		init : function() {
			$("#back").on("click", function() {
				wddp();
			});

			$("#container1 ul li").on("click",function() {
						var index = $(this).index();
						$("#container1 ul li").removeClass("router-link-exact-active");
						$("#container1 ul li").removeClass("active");
						$("#container1 ul li").eq(index).addClass("router-link-exact-active");
						$("#container1 ul li").eq(index).addClass("active");
						$("form").hide();
						$("form").eq(index).show();
					});

			$("#saveZl").on("click",
					function() {
						if (!member.xgzl.validation1()) {
							return;
						}
						var inputs = $("input.info");
						if (inputs.length == 0) {
							tips.alert("已填写的信息无法修改", 3000);
							return;
						}
						var cheng = load_open();
						var json = "{";
						for ( var i = 0; i < inputs.length; i++) {
							if (i == 0) {
								json += $(inputs[i]).attr("id") + " : '"
										+ $(inputs[i]).val() + "'";
							} else {
								json += ", " + $(inputs[i]).attr("id") + " : '"
										+ $(inputs[i]).val() + "'";
							}
						}
						json += "}";
						var para = eval('(' + json + ')');

						$.ajax({
							url : "lottery/updateZl.do",
							type : "POST",
							data : para,
							dataType : "json",
							success : function(data) {
								load_close(cheng);
								if(data==-1000){
									tisAlert();
									return;
								}
								if (data.status == "6") {
									getloginpage();
								}else if(data.status=="1"){
									tips.alert(data.message);
								}else {
// tips.alert(data.message);
									layer.open({
										type : 1,
										skin : "role_btn1",
										title : '提示',
										area : "70%",
										shadeClose : true,
										content : "<span style='font-size: 15px;margin-left: 14px;'>"+data.message+",马上充值</span>",
										btn : [ "马上去"],
										yes : function(index) {
											getCztx();
											layer.close(index);
										}
									});
								}
							},
							error : function(x, h, e) {
								load_closeAll();
							}
						});
					});

			$("#savePassword").on("click", function() {
				if (!member.xgzl.validation2()) {
					return;
				}
				var index = load_open();
				var encrypt = new JSEncrypt();
				encrypt.setPublicKey(PUBLIC_KEY);
				$.ajax({
					url : "lottery/updatePassword.do",
					type : "POST",
					data : {
						op : encrypt.encrypt($("#oldpassword_in_edit").val()),
						np : encrypt.encrypt($("#password_in_edit").val()),
						rnp : encrypt.encrypt($("#confirmed_password_in_edit").val())
					},
					dataType : "json",
					success : function(data) {
						load_close(index);
						if(data==-1000){
							tisAlert();
							return;
						}
						if (data.status == "6") {
							getloginpage();
						} else {
							tips.alert(data.message);
						}
					},
					error : function(x, h, e) {
						load_closeAll();
					}
				});
			});

			$("#next1").on("click", function() {
				if (!member.xgzl.validation3()) {
					return;
				}
				var index = load_open();
				var encrypt = new JSEncrypt();
				encrypt.setPublicKey(PUBLIC_KEY);
				$.ajax({
					url : "lottery/checkPassword.do",
					type : "POST",
					data : {
						hymm : encrypt.encrypt($("#aqwt_mm").val())
					},
					dataType : "json",
					success : function(data) {
						load_close(index);
						if(data==-1000){
							tisAlert();
							return;
						}
						if (data.status == "6") {
							getloginpage();
						} else {
							if (data.message == "0") {
								tips.alert("密码错误");
							} else if (data.message == "1") {
								$("form").hide();
								$("#aqwt").show();
							} else {
								tips.alert(data.message);
							}
						}
					},
					error : function(x, h, e) {
						load_closeAll();
					}
				});
			});

			$("#next2").on("click", function() {
				if (!member.xgzl.validation4()) {
					return;
				}
				var index = load_open();
				$.ajax({
					url : "lottery/updateAqwt.do",
					type : "POST",
					data : {
						aqwt1 : $("#aqwt1").val(),
						aqwt1da : $("#secure_code_in_finding").val()
					},
					dataType : "json",
					success : function(data) {
						load_close(index);
						if(data==-1000){
							tisAlert();
							return;
						}
						if (data.status == "6") {
							getloginpage();
						} else if (data.status == "4") {
							layer.alert(data.message);
							wddp();
						}
					},
					error : function(x, h, e) {
						load_closeAll();
					}
				});
			});
		},
		validation1 : function() {
// var reg = /^\d{4}$/;
// if (!$("#tel").prop("readonly") && $("#tel").val().trim() != ""
// && !reg.test($("#tel").val())) {
// tips.alert("手机号码格式错误,请填写后4位");
// return false;
// }
//			
// var reg = /^\d{4}$/;
// if ($("#tel").val().trim() == "") {
// tips.alert("请填写手机号码后4位");
// return false;
// }
			var reg = /^[0-9]{11}$/;
			if (!$("#tel").prop("readonly") && $("#tel").val().trim() != ""
					&& !reg.test($("#tel").val())) {
				tips.alert("手机号码错误");
				return false;
			}
			reg = /^.{1,15}$/;
			if (!$("#hymc").prop("readonly") && $("#hymc").val().trim() != ""
					&& !reg.test($("#hymc").val())) {
				tips.alert("姓名格式错误");
				return false;
			}
			reg = /^.{1,35}$/;
			if (!$("#yhmc").prop("readonly") && $("#yhmc").val().trim() != ""
					&& !reg.test($("#yhmc").val())) {
				tips.alert("银行名称格式错误");
				return false;
			}
			reg = /^.{1,20}$/;
			if (!$("#yhkh").prop("readonly") && $("#yhkh").val().trim() != ""
					&& !reg.test($("#yhkh").val())) {
				tips.alert("银行卡号错误");
				return false;
			}
// reg = /^[1-9]\d{4,10}$/;
// if (!$("#qq").prop("readonly") && $("#qq").val().trim() != ""
// && !reg.test($("#qq").val())) {
// tips.alert("qq号码格式错误");
// return false;
// }
// reg = /^.+@.+$/;
// if (!$("#email").prop("readonly") && $("#email").val().trim() != ""
// && !reg.test($("#email").val())) {
// tips.alert("电子邮箱格式错误");
// return false;
// }
			return true;
		},
		validation2 : function() {
			var reg = /^\w{6,20}$/;
			if (!reg.test($("#oldpassword_in_edit").val())) {
				tips.alert("原始密码格式错误");
				return false;
			}
			if (!reg.test($("#password_in_edit").val())) {
				tips.alert("新密码格式错误");
				return false;
			}
			if ($("#oldpassword_in_edit").val() == $("#password_in_edit").val()) {
				tips.alert("新密码不能与旧密码相同");
				return false;
			}
			if ($("#confirmed_password_in_edit").val() != $("#password_in_edit")
					.val()) {
				tips.alert("密码不一致");
				return false;
			}
			return true;
		},
		validation3 : function() {
			var reg = /^\w{6,20}$/;
			if (!reg.test($("#aqwt_mm").val())) {
				tips.alert("登录密码格式错误");
				return false;
			}
			return true;
		},
		validation4 : function() {
			var reg = /^\w{6,20}$/;
			if (!reg.test($("#aqwt_mm").val())) {
				tips.alert("登录密码格式错误");
				return false;
			}
			return true;
		}
	},
	// 银行卡信息
	yhkxx : {
		init : function() {
			$("#back").on("click", function() {
				wddp();
			});

			$("#container1 ul li").on(
					"click",
					function() {
						var index = $(this).index();
						$("#container1 ul li").removeClass(
								"router-link-exact-active");
						$("#container1 ul li").removeClass("active");
						$("#container1 ul li").eq(index).addClass(
								"router-link-exact-active");
						$("#container1 ul li").eq(index).addClass("active");
						$("form").hide();
						$("form").eq(index).show();
					});

			$("#saveYhkxx").on("click", function() {
				if (!member.yhkxx.validation1()) {
					return;
				}
				var index = load_open();
				$.ajax({
					url : "lottery/updateYhkxx.do",
					type : "POST",
					data : {
						yhkh : $("#yhkh").val(),
						yhmc : $("#yhmc").val()
					},
					dataType : "json",
					success : function(data) {
						load_close(index);
						if(data==-1000){
							tisAlert();
							return;
						}
						if (data.status == "6") {
							getloginpage();
						} else if (data.status == "4") {
							tips.alert(data.message);
							$("#saveYhkxx").remove();
						} else {
							tips.alert(data.message);
						}
					},
					error : function(x, h, e) {
						load_closeAll();
					}
				});
			});

			$("#saveZjmm").on("click", function() {
				if (!member.yhkxx.validation2()) {
					return;
				}
				var index = load_open();
				var encrypt = new JSEncrypt();
				encrypt.setPublicKey(PUBLIC_KEY);
				$.ajax({
					url : "lottery/updateZjmm.do",
					type : "POST",
					data : {
						op : encrypt.encrypt($("#op").val()),
						p1 : encrypt.encrypt($("#oldpassword_in_edit").val()),
						p2 : encrypt.encrypt($("#password_in_edit").val())
					},
					dataType : "json",
					success : function(data) {
						load_close(index);
						if(data==-1000){
							tisAlert();
							return;
						}
						if (data.status == "6") {
							getloginpage();
						} else if (data.status == "4") {
							tips.alert(data.message);
							wddp();
						} else {
							tips.alert(data.message);
						}
					},
					error : function(x, h, e) {
						load_closeAll();
					}
				});
			});
		},
		validation1 : function() {
			var reg = /^.{10,40}$/;
			if ($("#khm").val() == "") {
				tips.alert("请在修改资料中设置真实姓名");
				return false;
			}
			if (!reg.test($("#yhkh").val())) {
				tips.alert("卡号错误,只能填写银行卡号");
				return false;
			}
			reg = /^.{3,25}$/;
			if (!reg.test($("#yhmc").val())) {
				tips.alert("开户银行格式错误");
				return false;
			}
			reg = /^.*\d.*$/;
			if (reg.test($("#yhmc").val())) {
				tips.alert("开户银行不能有数字");
				return false;
			}
			return true;
		},
		validation2 : function() {
			var reg = /^\w{6,20}$/;
			if (!reg.test($("#oldpassword_in_edit").val())) {
				tips.alert("密码格式不正确");
				return false;
			}
			if ($("#oldpassword_in_edit").val() == $("#op").val()) {
				tips.alert("新密码不能与旧密码相同");
				return false;
			}
			if ($("#oldpassword_in_edit").val() != $("#password_in_edit").val()) {
				tips.alert("密码不一致");
				return false;
			}
			return true;
		}
	},
	// 开奖记录
	kjjl : {
		init : function(cpzl,flag,wfbm1,fjmoney) {
			member.kjjl.flag = flag;
			kjjl(cpzl,1,10);
			$(".index-back").on("click", function() {
				if (flag == undefined) {
					wddp();
				}else if((cpzl==51 || cpzl==52 || cpzl==53 || cpzl==54 || cpzl==55 || cpzl ==56 ||
						cpzl==57 || cpzl==58 || cpzl==59 ||cpzl==60 || cpzl==61 || cpzl==62 || cpzl==75 || cpzl==76 || cpzl==77)&& wfbm1!=undefined){
					fjLotteryBtn(wfbm1,fjmoney);
				} else {
					getintoLottery(cpzl);
				}
			});

			/*
			 * $("#first").on( "click", function() { var pagenum = 1; var qssj =
			 * $("#qssj").val(); var jzsj = $("#jzsj").val(); var cpzl =
			 * $("#cpzl").val(); var cpqh = $("#cpqh").val();
			 * getKjjl(member.kjjl.pagesize, pagenum, qssj, jzsj, cpzl, cpqh,
			 * member.kjjl.flag); });
			 * 
			 * $("#last").on( "click", function() { var pagenum = tn == 0 ? 1 :
			 * tn; var qssj = $("#qssj").val(); var jzsj = $("#jzsj").val(); var
			 * cpzl = $("#cpzl").val(); var cpqh = $("#cpqh").val();
			 * getKjjl(member.kjjl.pagesize, pagenum, qssj, jzsj, cpzl, cpqh,
			 * member.kjjl.flag); });
			 * 
			 * $("#prev").on( "click", function() { var pagenum; if (tn == 0 ||
			 * tn == 1) { pagenum = 1; } else { if (pn > 1) { pagenum = pn - 1; }
			 * else { pagenum = 1; }
			 *  } var qssj = $("#qssj").val(); var jzsj = $("#jzsj").val(); var
			 * cpzl = $("#cpzl").val(); var cpqh = $("#cpqh").val();
			 * getKjjl(member.kjjl.pagesize, pagenum, qssj, jzsj, cpzl, cpqh,
			 * member.kjjl.flag); });
			 * 
			 * $("#next").on( "click", function() { var pagenum; if (tn == 0 ||
			 * tn == 1) { pagenum = 1; } else { if (pn < tn) { pagenum = pn + 1; }
			 * else { pagenum = pn; }
			 *  } var qssj = $("#qssj").val(); var jzsj = $("#jzsj").val(); var
			 * cpzl = $("#cpzl").val(); var cpqh = $("#cpqh").val();
			 * getKjjl(member.kjjl.pagesize, pagenum, qssj, jzsj, cpzl, cpqh,
			 * member.kjjl.flag); });
			 */

			$("#filter").on("click",function() {
						layer.open({
							type : 1,
							skin : "role_btn7",
							title : '过滤',
							area : '90%',
							btn : "确定",
							shadeClose : true,
							content : $(".promptbox-wrapper"),
							yes : function(index) {
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var cpzl = $("#cpzl").val();
								var cpqh = $("#cpqh").val();
								layer.close(index);
								getKjjl(member.kjjl.pagesize, 1, qssj, jzsj,
										cpzl, cpqh, member.kjjl.flag);
							}
						});
					});
		},
		pagesize : 5,
		flag : 1
	},
	// 今日注单
	jrzd : {
		init : function(cpzl, flag,wfbm1,fjmoney) {
			member.jrzd.flag = flag;

			$(".index-back").on("click", function() {
				if (flag == undefined) {
					wddp();
				}else if((cpzl==51 || cpzl==52 || cpzl==53 || cpzl==54 || cpzl==55 || cpzl ==56 ||
						cpzl==57 || cpzl==58 || cpzl==59 ||cpzl==60 || cpzl==61 || cpzl==62 || cpzl==75 || cpzl==76 || cpzl==77)&& wfbm1!=undefined){
					fjLotteryBtn(wfbm1,fjmoney);
				} else {
					getintoLottery(cpzl);
				}
			});
// $("#back").on("click", function() {
// if (flag == undefined) {
// wddp();
// } else {
// getintoLottery(cpzl);
// }
// });

		},
		flag : 1
	},
	// 下注记录
	xzjl : {
		init : function(cpzl, flag,wfbm1,fjmoney) {
			member.xzjl.flag = flag;

			$(".index-back").on("click", function() {
				if (flag == undefined) {
					wddp();
				}else if((cpzl==51 || cpzl==52 || cpzl==53 || cpzl==54 || cpzl==55 || cpzl ==56 ||
						cpzl==57 || cpzl==58 || cpzl==59 ||cpzl==60 || cpzl==61 || cpzl==62 || cpzl==75 || cpzl==76 || cpzl==77)&& wfbm1!=undefined){
					fjLotteryBtn(wfbm1,fjmoney);
				} else {
					getintoLottery(cpzl);
				}
			});

			$("#first").on(
					"click",
					function() {
						var pagenum = 1;
						var qssj = $("#qssj").val();
						var jzsj = $("#jzsj").val();
						var cpzl = $("#cpzl").val();
						var tzzt = $("#tzzt").val();
						getXzjl(member.xzjl.pagesize, pagenum, qssj, jzsj,
								cpzl, tzzt, member.xzjl.flag,wfbm1,fjmoney);
					});

			$("#last").on(
					"click",
					function() {
						var pagenum = tn == 0 ? 1 : tn;
						var qssj = $("#qssj").val();
						var jzsj = $("#jzsj").val();
						var cpzl = $("#cpzl").val();
						var tzzt = $("#tzzt").val();
						getXzjl(member.xzjl.pagesize, pagenum, qssj, jzsj,
								cpzl, tzzt, member.xzjl.flag,wfbm1,fjmoney);
					});

			$("#prev").on(
					"click",
					function() {
						var pagenum;
						if (tn == 0 || tn == 1) {
							pagenum = 1;
						} else {
							if (pn > 1) {
								pagenum = pn - 1;
							} else {
								pagenum = 1;
							}

						}
						var qssj = $("#qssj").val();
						var jzsj = $("#jzsj").val();
						var cpzl = $("#cpzl").val();
						var tzzt = $("#tzzt").val();
						getXzjl(member.xzjl.pagesize, pagenum, qssj, jzsj,
								cpzl, tzzt, member.xzjl.flag,wfbm1,fjmoney);
					});

			$("#next").on(
					"click",
					function() {
						var pagenum;
						if (tn == 0 || tn == 1) {
							pagenum = 1;
						} else {
							if (pn < tn) {
								pagenum = pn + 1;
							} else {
								pagenum = pn;
							}

						}
						var qssj = $("#qssj").val();
						var jzsj = $("#jzsj").val();
						var cpzl = $("#cpzl").val();
						var tzzt = $("#tzzt").val();
						getXzjl(member.xzjl.pagesize, pagenum, qssj, jzsj,
								cpzl, tzzt, member.xzjl.flag,wfbm1,fjmoney);
					});

			$("#filter").on(
					"click",
					function() {
						layer.open({
							type : 1,
							skin : "role_btn7",
							title : '过滤',
							area : '90%',
							btn : "确定",
							shadeClose : true,
							content : $(".promptbox-wrapper"),
							yes : function(index) {
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var cpzl = $("#cpzl").val();
								var tzzt = $("#tzzt").val();
								layer.close(index);
								getXzjl(member.xzjl.pagesize, 1, qssj, jzsj,
										cpzl, tzzt, member.xzjl.flag,wfbm1,fjmoney);
							}
						});
					});

			$(".cd").on("click",function() {
						var sn = $(this).attr("sn");
						var cpzl = $(this).attr("cpzl");
						layer.confirm('确定撤单？', {
							  btn: ['确认','取消'] // 按钮
							}, function(){
								var index = load_open();
								$.ajax({
											url : "lottery/cd.do",
											type : "POST",
											dataType : "json",
											data : {
												sn : sn,
												cpzl : cpzl
											},
											success : function(data) {
												load_close(index);
												var qssj = $("#qssj").val();
												var jzsj = $("#jzsj").val();
												var cpzl = $("#cpzl").val();
												var tzzt = $("#tzzt").val();
												layer.alert(data.message);
												getXzjl(member.xzjl.pagesize, 1,
														qssj, jzsj, cpzl, tzzt,
														member.xzjl.flag,wfbm1,fjmoney);
											},
											error : function(x, h, e) {
												load_closeAll();
											}
										});
							
							}, function(){
								load_closeAll();
							});
					});
		},
		pagesize : 20,
		flag : 1
	},
	// 账户流水
	zhls : {
		init : function() {
			$("#back").on("click", function() {
				wddp();
			});

			$("#first").on("click", function() {
				var pagenum = 1;
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var zblx = $("#zblx").val();
				getZhls(member.zhls.pagesize, pagenum, qssj, jzsj, zblx);
			});

			$("#last").on("click", function() {
				var pagenum = tn == 0 ? 1 : tn;
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var zblx = $("#zblx").val();
				getZhls(member.zhls.pagesize, pagenum, qssj, jzsj, zblx);
			});

			$("#prev").on("click", function() {
				var pagenum;
				if (tn == 0 || tn == 1) {
					pagenum = 1;
				} else {
					if (pn > 1) {
						pagenum = pn - 1;
					} else {
						pagenum = 1;
					}

				}
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var zblx = $("#zblx").val();
				getZhls(member.zhls.pagesize, pagenum, qssj, jzsj, zblx);
			});

			$("#next").on("click", function() {
				var pagenum;
				if (tn == 0 || tn == 1) {
					pagenum = 1;
				} else {
					if (pn < tn) {
						pagenum = pn + 1;
					} else {
						pagenum = pn;
					}

				}
				var qssj = $("#qssj").val();
				var jzsj = $("#jzsj").val();
				var zblx = $("#zblx").val();
				getZhls(member.zhls.pagesize, pagenum, qssj, jzsj, zblx);
			});

			$("#filter").on("click", function() {
				layer.open({
					type : 1,
					skin : "role_btn7",
					title : '过滤',
					area : '90%',
					btn : "确定",
					shadeClose : true,
					content : $(".promptbox-wrapper"),
					yes : function(index) {
						var qssj = $("#qssj").val();
						var jzsj = $("#jzsj").val();
						var zblx = $("#zblx").val();
						layer.close(index);
						getZhls(member.zhls.pagesize, 1, qssj, jzsj, zblx);
					}
				});
			});
		},
		pagesize : 5
	},
	// 个人盈亏
	gryk : {
		init : function() {
			$("#back").on("click", function() {
				wddp();
			});

			$("#search").on(
					"click",
					function() {
						getDlyk($("#kssj").val(), $("#jssj").val(),
								$("#hydlmc").val());
					});
		}
	},
	// 代理盈亏
	dlyk : {
		init : function() {
			$("#back").on("click", function() {
				wddp();
			});

			$("#search").on(
					"click",
					function() {
						getDlyk($("#kssj").val(), $("#jssj").val(),
								$("#hydlmc").val(), $(this).attr("hybm"), $(
										this).attr("name"));
					});
		}
	}
};

var zjgl = {
	cztx : {
		init : function() {
			member.cztx.clipboard_ac = new Clipboard(".copy1");
			member.cztx.clipboard_ac.on("success", function(element) {// 复制成功的回调
				load_closeAll();
				tips.alert("已复制到剪切板");
			});
			member.cztx.clipboard_ac.on("error", function(element) {// 复制失败的回调
				tips.alert("请长按链接手动复制");
			});
			$("#back").on("click", function() {
				if (typeof (clipboard1) != 'undefined') {
					clipboard1.destroy();
				}
				if (typeof (clipboard1_xm) != 'undefined') {
					clipboard1_xm.destroy();
				}
				if (typeof (clipboard1_zh) != 'undefined') {
					clipboard1_zh.destroy();
				}
				if (typeof (clipboard2) != 'undefined') {
					clipboard2.destroy();
				}
				if (typeof (clipboard2_xm) != 'undefined') {
					clipboard2_xm.destroy();
				}
				if (typeof (clipboard2_zh) != 'undefined') {
					clipboard2_zh.destroy();
				}

				if (typeof (member.cztx.clipboard_ac) != 'undefined') {
					member.cztx.clipboard_ac.destroy();
				}
				index();
			});

			$("#container1 ul.nostyle.account-sub-nav.account-sub1.kd-row-middle li").on(
					"click",
					function() {
						var index = $(this).index();
						if (index == 0) {
							$("#container1 ul li").removeClass(
									"router-link-exact-active");
							$("#container1 ul li").removeClass("active");
							$("#container1 ul li").eq(0).addClass(
									"router-link-exact-active");
							$("#container1 ul li").eq(0).addClass("active");
							$("#tx1").hide();
							$("#jyjl").hide();
							$("#cz2").hide();
							$("#cz1").show();
						} else if (index == 1) {
							$("#container1 ul li").removeClass(
									"router-link-exact-active");
							$("#container1 ul li").removeClass("active");
							$("#container1 ul li").eq(1).addClass(
									"router-link-exact-active");
							$("#container1 ul li").eq(1).addClass("active");
							$("#cz1").hide();
							$("#jyjl").hide();
							$("#tx1").hide();
							$("#cz2").show();
						}  else {
							getJyjl(1);
						}
					});
			$("#container1 ul.nostyle.account-sub-nav.account-sub2.kd-row-middle li").on(
					"click",
					function() {
						var index = $(this).index();
						if (index == 0) {
							$("#container1 ul li").removeClass(
									"router-link-exact-active");
							$("#container1 ul li").removeClass("active");
							$("#container1 ul li").eq(0).addClass(
									"router-link-exact-active");
							$("#container1 ul li").eq(0).addClass("active");
							$("#cz1").hide();
							$("#cz2").hide();
							$("#jyjl").hide();
							$("#tx1").show();
						} else {
							getJyjl(2);
						}
					});


			// $("div.type-title.kd-container.Collapsing").on("click",
			// function(){
			// if($(this).hasClass("current")){
			// $(this).removeClass("current");
			// $(this).next().hide();
			// }else{
			// $(this).addClass("current");
			// $("div.type-body.coll_body").hide();
			// $(this).next().show();
			// }
			// });
			$("div.Collapsing.topup_czbs").on("click", function() {
				if ($(this).hasClass("current")) {
					$(this).removeClass("current");
					$(this).next().hide();
					$(".kd-form .topup_czbs").removeClass("topup_top");
				} else {
					$(this).addClass("current");
					$("div.type-body.coll_body").hide();
					$(this).next().show();
					$(this).addClass("topup_top");
				}
			});

			// 提现提交业务
			$("#tx").on(
					"click",
					function() {
						if (!member.cztx.validation()) {
							return;
						}
						var index = load_open();
						$.ajax({
							url : "lottery/getPoundage.do",
							data : {
								"txje" : $("#txje").val()
							},
							type : 'post',
							cache : false,
							dataType : 'text',
							success : function(data) {
								var money = parseFloat(data);
								load_close(index);
								if ((money != 0 && confirm("将收取" + data
										+ "元手续费，确定继续提现操作？"))
										|| money == 0) {
									var index1 = load_open();
									var encrypt = new JSEncrypt();
									encrypt.setPublicKey(PUBLIC_KEY);
									$.ajax({
										url : "lottery/tx.do",
										data : {
											"txje" : $("#txje").val(),
											"hyzfmm" :  encrypt.encrypt($("#hyzfmm").val()),
											"yhkxxsn" : $("#yhkxxsn").val()
										},
										type : 'post',
										cache : false,
										dataType : 'json',
										success : function(data) {
											load_close(index1);
											if(data==-1000){
												tisAlert();
												return;
											}
											if (data.status == "6") {
												getloginpage();
											} else if (data.status == "4") {
												layer.alert(data.message);
												wddp();
												// 发送提现信息到后台
												// sendMessageWithType("tx");
											} else {
												tips.alert(data.message);
											}
										},
										error : function() {
											load_closeAll();
										}
									});
								}
							},
							error : function() {
								load_closeAll();
							}
						});
					});
		},
		validation : function() {
			var reg = /^\d{1,9}$/;
			if (!reg.test($("#txje").val())) {
				tips.alert("提现金额必须为整数");
				return false;
			}
			reg = /^\w{6,20}$/;
			if (!reg.test($("#hyzfmm").val())) {
				tips.alert("支付密码格式错误");
				return false;
			}
			return true;
		},
		// 交易记录
		jyjl : {
			init : function() {
				$("#back").on("click", function() {
					getCztxInFooter();
				});

				$("#container1 ul li")
						.on(
								"click",
								function() {
									var index = $(this).index();
									$("#container1 ul li").removeClass(
											"router-link-exact-active");
									$("#container1 ul li")
											.removeClass("active");
									$("#container1 ul li").eq(index).addClass(
											"router-link-exact-active");
									$("#container1 ul li").eq(index).addClass(
											"active");
									$(".czjy_jl").hide();
									$(".czjy_jl").eq(index).show();
								});

				$("#filter_czjl").on(
						"click",
						function() {
							layer.open({
								type : 1,
								skin : "role_btn7",
								title : '过滤',
								area : '90%',
								btn : "确定",
								shadeClose : true,
								content : $("#cz"),
								yes : function(index) {
									layer.close(index);
									var qssj = $("#qssj").val();
									var jzsj = $("#jzsj").val();
									var czlx = $("#czlx").val();
									var czzt = $("#czzt").val();
									getCzjl(member.cztx.jyjl.czjl.pagesize, 1,
											qssj, jzsj, czlx, czzt);
								}
							});
						});

				$("#filter_txjl").on(
						"click",
						function() {
							layer.open({
								type : 1,
								skin : "role_btn7",
								title : '过滤',
								area : '90%',
								btn : "确定",
								shadeClose : true,
								content : $("#tx"),
								yes : function(index) {
									layer.close(index);
									var qssj = $("#qssj_txjl").val();
									var jzsj = $("#jzsj_txjl").val();
									var txzt = $("#txzt").val();
									getTxjl(member.cztx.jyjl.txjl.pagesize, 1,
											qssj, jzsj, txzt);
								}
							});
						});
			},
			czjl : {
				pagesize : 5,
				init : function() {
					$("#first_czjl").on(
							"click",
							function() {
								var pagenum = 1;
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var czlx = $("#czlx").val();
								var czzt = $("#czzt").val();
								getCzjl(member.cztx.jyjl.czjl.pagesize,
										pagenum, qssj, jzsj, czlx, czzt);
							});

					$("#last_czjl").on(
							"click",
							function() {
								var pagenum = tn_czjl == 0 ? 1 : tn_czjl;
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var czlx = $("#czlx").val();
								var czzt = $("#czzt").val();
								getCzjl(member.cztx.jyjl.czjl.pagesize,
										pagenum, qssj, jzsj, czlx, czzt);
							});

					$("#prev_czjl").on(
							"click",
							function() {
								var pagenum;
								if (tn_czjl == 0 || tn_czjl == 1) {
									pagenum = 1;
								} else {
									if (pn_czjl > 1) {
										pagenum = pn_czjl - 1;
									} else {
										pagenum = 1;
									}

								}
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var czlx = $("#czlx").val();
								var czzt = $("#czzt").val();
								getCzjl(member.cztx.jyjl.czjl.pagesize,
										pagenum, qssj, jzsj, czlx, czzt);
							});

					$("#next_czjl").on(
							"click",
							function() {
								var pagenum;
								if (tn_czjl == 0 || tn_czjl == 1) {
									pagenum = 1;
								} else {
									if (pn_czjl < tn_czjl) {
										pagenum = pn_czjl + 1;
									} else {
										pagenum = pn_czjl;
									}

								}
								var qssj = $("#qssj").val();
								var jzsj = $("#jzsj").val();
								var czlx = $("#czlx").val();
								var czzt = $("#czzt").val();
								getCzjl(member.cztx.jyjl.czjl.pagesize,
										pagenum, qssj, jzsj, czlx, czzt);
							});
				}
			},
			txjl : {
				pagesize : 5,
				init : function() {
					$("#first_txjl").on(
							"click",
							function() {
								var pagenum = 1;
								var qssj = $("#qssj_txjl").val();
								var jzsj = $("#jzsj_txjl").val();
								var txzt = $("#txzt").val();
								getTxjl(member.cztx.jyjl.txjl.pagesize,
										pagenum, qssj, jzsj, txzt);
							});

					$("#last_txjl").on(
							"click",
							function() {
								var pagenum = tn_txjl == 0 ? 1 : tn_txjl;
								var qssj = $("#qssj_txjl").val();
								var jzsj = $("#jzsj_txjl").val();
								var txzt = $("#txzt").val();
								getTxjl(member.cztx.jyjl.txjl.pagesize,
										pagenum, qssj, jzsj, txzt);
							});

					$("#prev_txjl").on(
							"click",
							function() {
								var pagenum;
								if (tn_txjl == 0 || tn_txjl == 1) {
									pagenum = 1;
								} else {
									if (pn_txjl > 1) {
										pagenum = pn_txjl - 1;
									} else {
										pagenum = 1;
									}

								}
								var qssj = $("#qssj_txjl").val();
								var jzsj = $("#jzsj_txjl").val();
								var txzt = $("#txzt").val();
								getTxjl(member.cztx.jyjl.txjl.pagesize,
										pagenum, qssj, jzsj, txzt);
							});

					$("#next_txjl").on(
							"click",
							function() {
								var pagenum;
								if (tn_txjl == 0 || tn_txjl == 1) {
									pagenum = 1;
								} else {
									if (pn_txjl < tn_txjl) {
										pagenum = pn_txjl + 1;
									} else {
										pagenum = pn_txjl;
									}

								}
								var qssj = $("#qssj_txjl").val();
								var jzsj = $("#jzsj_txjl").val();
								var txzt = $("#txzt").val();
								getTxjl(member.cztx.jyjl.txjl.pagesize,
										pagenum, qssj, jzsj, txzt);
							});
				}
			}
		}
	}
};
/**
 * 注册页
 */
function zhuce(){
	var index = load_open();
	$.ajax({
		url : "lottery/registerpage.do",
		type : "POST",
		success : function(data) {
			load_close(index);
			$("#subContentId").html(data);
			commoninit();
			registerpage.init();
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

/*
 * 头部
 */
var head = {
	init : function() {
		var istrue = true;
		$("#right-ye").on("click", function() {
			if ($(this).attr("login") == "0") {
// return;
// getloginpage();
			} else {
				// $("#right-xs").toggle();
				istrue = !istrue;
				$("#right-xs").css("display", istrue ? "none" : "block");
			}
		});

		$("#zhuce").on("click", function() {
			zhuce();
		});
		
		$("#denglu").on("click", function() {
			getloginpage();
		});
		
		$("#container1").click(function() {
			$("#right-xs").css("display", "none");
			istrue = true;
		});

		$("#right-xs li").on("click", function() {
			var a = $(this).find("a").html();
			if (a == "我的地盘") {
				mark = 3;
				wddp();
			} else if (a == "安全退出") {
				logout();
			}else if (a == "代理推广"){
				getDltg();
			}else if(a == "系统消息"){
				getXxzx();
			}
		});
	}
};

/*
 * 忘记密码
 */
function getWjmm() {
	var index = load_open();
	$.ajax({
		url : "lottery/wjmm.do",
		type : "POST",
		dataType : "html",
		success : function(data) {
			$("#subContentId").empty();
			$("#subContentId").append(data);
			commoninit();
			loginpage.wjmm.init();
			load_close(index);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入首页
function index(flag) {
	var index = load_open();
	var serveruserid = $("#ServerUserId").val();
	if(serveruserid =='' || serveruserid==undefined){
		mainObj = mainPageObj[1];
	}else if($("#gly").val()==2){
		mainObj = mainPageObj[2];
	}else{
		mainObj = mainPageObj[3];
	}
	if(mainObj==null || mainObj==''){
		$.ajax({
			url : "lottery/redirectMain.do",
			type : "POST",
			success : function(data) {
				var obj = JSON.parse(data);
				$("#subContentId").empty();
				$("#subContentId").append(obj.data);
				$("#ServerUserId").val(obj.hybm == null ? '' : obj.hybm);
				$("#ServerUserName").val(obj.hymc == null ? '' : obj.hymc);
				$("#ServerUserXxsx").val(obj.xxsx == null ? '' : obj.xxsx);
				$("#gly").val(obj.gly == null ? '' : obj.gly);
				if(obj.hybm==null){
					mainPageObj[1]=data;
				}else if(obj.gly==2){
					mainPageObj[2]=data;
				}else{
					mainPageObj[3]=data;
				}
				if(serveruserid !='' && serveruserid!=undefined){
			    	getHyje();// 得到金额
			    }
				commoninit();
				maininit();
				// getHbIsInit();
				if (flag == 1) {
					tips.loginAlert();
				}
				load_close(index);
			},
			error : function(x, h, e) {
				load_closeAll();
			}
		});
	}else{
		var data = mainObj;
		var obj = JSON.parse(data);
		$("#subContentId").empty();
		$("#subContentId").append(obj.data);
		$("#ServerUserId").val(obj.hybm == null ? '' : obj.hybm);
		$("#ServerUserName").val(obj.hymc == null ? '' : obj.hymc);
		$("#ServerUserXxsx").val(obj.xxsx == null ? '' : obj.xxsx);
		$("#gly").val(obj.gly == null?'':obj.gly);
		commoninit();
		maininit();
		if(serveruserid !='' && serveruserid!=undefined){
	    	getHyje();// 得到金额
	    }
		// getHbIsInit();
		if (flag == 1) {
			tips.loginAlert();
		}
		load_close(index);
	}
}

// 进入登录页===登陆
function getloginpage() {
	$("#ServerUserId").val("");
	$("#ServerUserName").val("");
	$("#ServerUserXxsx").val("");
	$("#gly").val("");
	webSeocketClose();
	$.ajax({
		url : "lottery/loginpage.do",
		type : "POST",
		dataType : "html",
		success : function(data) {
			$("#subContentId").html(data);
			commoninit();
			loginpage.init();
			loginLocalstore();// 登陆存储
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入我的地盘
function wddp() {
	var index = load_open();
	$.ajax({
		url : "lottery/memberpage.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				lotteryPage();// 彩种页面
				lotteryBtn();// 彩票按钮初始化
				member.init();
			}
			load_close(index);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 优惠活动
function getYhhd() {
	var index = load_open();
	$.ajax({
		url : "lottery/yhhd.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				menu.yhhd.init();
				load_close(index);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 代理推广
function getDltg() {
	var index = load_open();
	$.ajax({
		url : "lottery/dltg.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.dltg.init();
			}
			load_close(index);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入充值/提现
function getCztx(cpzl,wfbm1,fjmoney) {
	load_closeAll();
	var index = load_open();
	$.ajax({
		url : "lottery/cztx.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else if (data.status == "4") {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.cztx.init(cpzl,wfbm1,fjmoney);
			} else if (data.status == "0") {
				alertBind();
			}else if(data.status=="5"){
				layer.open({
					type : 1,
					skin : "role_btn1",
					title : '提示',
					area : "80%",
					shadeClose : true,
					content : "<span style='font-size: 17px;margin-left: 14px;'>请先正确填写资料和银行卡后，方可充值提现</span>",
					btn : [ "马上去"],
					yes : function(index) {
						getXgzl();
						layer.close(index);
					}
				});
			}
			load_close(index);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}


// 进入充值/提现
function getTx(cpzl) {
	load_closeAll();
	var index = load_open();
	$.ajax({
		url : "lottery/txPage.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else if (data.status == "4") {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.cztx.init(cpzl);
			} else if (data.status == "0") {
				alertBind();
			}
			load_close(index);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入充值/提现
function getCztxInFooter() {
	var index = load_open();
	$.ajax({
		url : "lottery/cztx.do?type=1",
		type : "POST",
		dataType : "json",
		success : function(data) {
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else if (data.status == "4") {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				zjgl.cztx.init();
			} else if (data.status == "0") {
				alertBind();
			}else if(data.status=="5"){
				layer.open({
					type : 1,
					skin : "role_btn1",
					title : '提示',
					area : "80%",
					shadeClose : true,
					content : "<span style='font-size: 17px;margin-left: 14px;'>请先正确填写资料和银行卡后，方可充值和提现</span>",
					btn : [ "马上去"],
					yes : function(index) {
						getXgzl();
						layer.close(index);
					}
				});
			}
			load_close(index);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入交易记录
function getJyjl(cttype) {
	var index = load_open();
	$.ajax({
		url : "lottery/jyjl.do",
		type : "POST",
		data : {"type":cttype},
		dataType : "json",
		success : function(data) {
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.cztx.jyjl.init();
				if(cttype==1){
					getCzjl();
				}else{
					getTxjl();
				}

				
			}
			load_close(index);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function getJyjlInFooter() {
	var index = load_open();
	$.ajax({
		url : "lottery/jyjl.do?type=1",
		type : "POST",
		dataType : "json",
		success : function(data) {
			load_close(index);
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				zjgl.cztx.jyjl.init();
				getCzjl();
				getTxjl();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 充值记录
function getCzjl(pagesize, pagenum, qssj, jzsj, czlx, czzt) {
	if (pagesize == undefined) {
		pagesize = 5;
	}
	if (pagenum == undefined) {
		pagenum = 1;
	}
	if (qssj == undefined) {
		qssj = "";
	}
	if (jzsj == undefined) {
		jzsj = "";
	}
	if (czlx == undefined) {
		czlx = "";
	}
	if (czzt == undefined) {
		czzt = "";
	}
	var index = load_open();
	$.ajax({
		url : "lottery/czjl.do",
		type : "POST",
		data : {
			pagesize : pagesize,
			pagenum : pagenum,
			qssj : qssj,
			jzsj : jzsj,
			czlx : czlx,
			czzt : czzt
		},
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#czjl").empty();
				$("#czjl").append(data.message);
				member.cztx.jyjl.czjl.init();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 提现记录
function getTxjl(pagesize, pagenum, qssj, jzsj, txzt) {
	if (pagesize == undefined) {
		pagesize = 5;
	}
	if (pagenum == undefined) {
		pagenum = 1;
	}
	if (qssj == undefined) {
		qssj = "";
	}
	if (jzsj == undefined) {
		jzsj = "";
	}
	if (txzt == undefined) {
		txzt = "";
	}
	var index = load_open();
	$.ajax({
		url : "lottery/txjl.do",
		type : "POST",
		data : {
			pagesize : pagesize,
			pagenum : pagenum,
			qssj : qssj,
			jzsj : jzsj,
			txzt : txzt
		},
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#txjl").empty();
				$("#txjl").append(data.message);
				member.cztx.jyjl.txjl.init();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入修改资料
function getXgzl() {
	var index = load_open();
	$.ajax({
		url : "lottery/xgzl.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.xgzl.init();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入银行卡信息
function getYhkxx() {
	var index = load_open();
	$.ajax({
		url : "lottery/yhkxx.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.yhkxx.init();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入消息中心
function getXxzx(pagesize, pagenum, qssj, jzsj, xxlx, xxzt) {
	if (pagesize == undefined) {
		pagesize = 5;
	}
	if (pagenum == undefined) {
		pagenum = 1;
	}
	if (qssj == undefined) {
		qssj = "";
	}
	if (jzsj == undefined) {
		jzsj = "";
	}
	if (xxlx == undefined) {
		xxlx = "";
	}
	if (xxzt == undefined) {
		xxzt = 0;
	}
	var index = load_open();
	$.ajax({
		url : "lottery/xxzx.do",
		type : "POST",
		data : {
			pagesize : pagesize,
			pagenum : pagenum,
			qssj : qssj,
			jzsj : jzsj,
			xxlx : xxlx,
			xxzt : xxzt
		},
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.xxzx.init();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function markXx(qssj, jzsj, xxlx, sn) {
	var index = load_open();
	$.ajax({
		url : "lottery/markXx.do",
		type : "POST",
		dataType : "json",
		data : {
			sn : sn
		},
		success : function(data) {
			load_close(index);
			if (data.status == "6") {
				getloginpage();
			} else {
				getXxzx(member.xxzx.pagesize, 1, qssj, jzsj, xxlx, 0);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function markAll(qssj, jzsj, xxlx, sn) {
	var index = load_open();
	$.ajax({
		url : "lottery/markXxs.do",
		type : "POST",
		dataType : "json",
		data : {
			sn : sn
		},
		success : function(data) {
			load_close(index);
			if (data.status == "6") {
				getloginpage();
			} else {
				getXxzx(member.xxzx.pagesize, 1, qssj, jzsj, xxlx, 0);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function delXx(qssj, jzsj, xxlx, sn) {
	var index = load_open();
	$.ajax({
		url : "lottery/delXx.do",
		type : "POST",
		dataType : "json",
		data : {
			sn : sn
		},
		success : function(data) {
			load_close(index);
			if (data.status == "6") {
				getloginpage();
			} else {
				getXxzx(member.xxzx.pagesize, 1, qssj, jzsj, xxlx, 1);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function delAll(qssj, jzsj, xxlx, sn) {
	var index = load_open();
	$.ajax({
		url : "lottery/delXxs.do",
		type : "POST",
		dataType : "json",
		data : {
			sn : sn
		},
		success : function(data) {
			load_close(index);
			if (data.status == "6") {
				getloginpage();
			} else {
				getXxzx(member.xxzx.pagesize, 1, qssj, jzsj, xxlx, 1);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入开奖记录
function getKjjl(pagesize, pagenum, qssj, jzsj, cpzl, cpqh, flag,wfbm1,fjmoney) {
	if (pagesize == undefined) {
		pagesize = 5;
	}
	if (pagenum == undefined) {
		pagenum = 1;
	}
	if (qssj == undefined) {
		qssj = "";
	}
	if (jzsj == undefined) {
		jzsj = "";
	}
	if (cpzl == undefined) {
		cpzl = "";
	}
	if (cpqh == undefined) {
		cpqh = "";
	}
	var index = load_open();
	$.ajax({
		url : "lottery/kjjl.do",
		type : "POST",
		dataType : "json",
		data : {
			pagesize : pagesize,
			pagenum : pagenum,
			qssj : qssj,
			jzsj : jzsj,
			cpzl : cpzl,
			cpqh : cpqh
		},
		success : function(data) {
			load_closeAll();
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.kjjl.init(cpzl, flag,wfbm1,fjmoney);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入今日注单
function getJrzd(cpzl, flag,fjbm1,fjmoney) {
	if (cpzl == undefined) {
		cpzl = "";
	}
	var index = load_open();
	$.ajax({
		url : "lottery/jrzd.do",
		type : "POST",
		dataType : "json",
		data : {
			cpzl : cpzl
		},
		success : function(data) {
			load_close(index);
			if (data.status == "6") {
				getloginpage();
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.jrzd.init(cpzl, flag,fjbm1,fjmoney);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入下注记录
function getXzjl(pagesize, pagenum, qssj, jzsj, cpzl, tzzt, flag,wfbm1,fjmoney) {
	if (pagesize == undefined) {
		pagesize = 20;
	}
	if (pagenum == undefined) {
		pagenum = 1;
	}
	if (qssj == undefined) {
		qssj = "";
	}
	if (jzsj == undefined) {
		jzsj = "";
	}
	if (cpzl == undefined) {
		cpzl = "";
	}
	if (tzzt == undefined) {
		tzzt = "";
	}
	var index = load_open();
	var para= {'pagesize': pagesize,'pagenum': pagenum,'qssj' : qssj,'jzsj' : jzsj,'cpzl' : cpzl,'tzzt' : tzzt,'wfbm1':wfbm1,'fjmoney':fjmoney};
	$.ajax({
		url : "lottery/xzjl.do",
		type : "POST",
		dataType : "json",
		data :para,
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.xzjl.init(cpzl, flag,wfbm1,fjmoney);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入账号流水
function getZhls(pagesize, pagenum, qssj, jzsj, zblx) {
	if (pagesize == undefined) {
		pagesize = 5;
	}
	if (pagenum == undefined) {
		pagenum = 1;
	}
	if (qssj == undefined) {
		qssj = "";
	}
	if (jzsj == undefined) {
		jzsj = "";
	}
	if (zblx == undefined) {
		zblx = "";
	}
	var index = load_open();
	$.ajax({
		url : "lottery/zhls.do",
		type : "POST",
		dataType : "json",
		data : {
			pagesize : pagesize,
			pagenum : pagenum,
			qssj : qssj,
			jzsj : jzsj,
			zblx : zblx
		},
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.zhls.init();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function getDlyk(kssj, jssj, hydlmc, hybm, name) {
	if (kssj == undefined) {
		kssj = "";
	}
	if (jssj == undefined) {
		jssj = "";
	}
	if (hydlmc == undefined) {
		hydlmc = "";
	}
	if (hybm == undefined) {
		hybm = "";
	}
	var index = load_open();
	$.ajax({
		url : "lottery/dlyk.do",
		type : "POST",
		data : {
			kssj : kssj,
			jssj : jssj,
			hydlmc : hydlmc,
			hybm : hybm,
			name : name
		},
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			}if(data.status == "1"){
				tips.alert(data.message);
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.dlyk.init();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function getGryk1() {
	var index = load_open();
	$.ajax({
		url : "lottery/gryk1.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "4") {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.gryk.init();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function dlykmx(hybm) {
	var index = load_open();
	$.ajax({
		url : "lottery/gryk.do",
		type : "POST",
		data : {
			hybm : hybm
		},
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "4") {
				$("#gryk div").html(data.message);
				layer.open({
					type : 1,
					skin : "role_btn5",
					title : '个人盈亏',
					area : [ '320px', '400px' ],
					shadeClose : true,
					content : $("#gryk")
				});
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 进入下注记录
function getXjtz(pagesize, pagenum, qssj, jzsj, cpzl, tzzt, flag) {
	if (pagesize == undefined) {
		pagesize = 20;
	}
	if (pagenum == undefined) {
		pagenum = 1;
	}
	if (qssj == undefined) {
		qssj = "";
	}
	if (jzsj == undefined) {
		jzsj = "";
	}
	if (cpzl == undefined) {
		cpzl = "";
	}
	if (tzzt == undefined) {
		tzzt = "";
	}
	var index = load_open();
	$.ajax({
		url : "lottery/xjtz.do",
		type : "POST",
		dataType : "json",
		data : {
			pagesize : pagesize,
			pagenum : pagenum,
			qssj : qssj,
			jzsj : jzsj,
			cpzl : cpzl,
			tzzt : tzzt
		},
		success : function(data) {
			load_close(index);
			if (data.status == "6") {
				getloginpage();
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.xzjl.init(cpzl, flag);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 退出登录
function logout() {
	layer.open({
		type : 1,
		skin : "role_btn1",
		title : '提示',
		area : "70%",
		shadeClose : true,
		content : $("#confirm"),
		btn : [ "确定", "取消" ],
		yes : function(index) {
			layer.close(index);
			var index1 = load_open();
			$("#ServerUserId").val("");
			$("#ServerUserName").val("");
			$("#ServerUserXxsx").val("");
			$("#gly").val("");
			webSeocketClose();
			$.ajax({
				url : "lottery/logout.do",
				type : "POST",
				dataType : "html",
				success : function(data) {
					load_close(index1);
					getloginpage();
				},
				error : function(x, h, e) {
					load_closeAll();
				}
			});
		},
		btn2 : function(index) {
			layer.close(index);
		}
	});
}

function logout1() {
	var index = load_open();
	$("#ServerUserId").val("");
	$("#ServerUserName").val("");
	$("#ServerUserXxsx").val("");
	$("#gly").val("");
	webSeocketClose();
	$.ajax({
		url : "lottery/logout.do",
		type : "POST",
		dataType : "html",
		success : function(data) {
			getloginpage();
			load_close(index);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// ////////////////////////更多彩种////////////////////////////////////////
/**
 * 更多彩种初始化
 */
function moreLotterinit() {
	getNotice1();

	lotteryBtn();// 彩票按钮

	// 进入主页
	$(".logo1").on("click", function() {
		index();
	});

	$(".cztx").on("click", function() {
		getCztx();
	});
}

function getApp() {
	var index1 = load_open();
	$.ajax({
		url : "lottery/getApp.do",
		type : "POST",
		dataType : "html",
		success : function(data) {
			load_close(index1);
			$("#subContentId").html(data);
			commoninit();
			$("#back").on("click", function() {
				if ($("#frame").is(":hidden")) {
					index();
				} else {
					$(".scroll").show();
					$("#frame").hide();
				}
			});
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}


// /////////////////////////////////////彩票公共部分/////////////////////////////////////////////////////////
var localArray = [];
var onetime = null;

/**
 * 彩票页面公共部门初始化
 */
function lotteryCommonInit() {
	var cpbm = Number($("#cpbm").val());
	$(".index-back").on('click',function(){
		index();
	});
	switch(cpbm){
		case 51,52,53,54,55,56,57,58,59,60,61,62,63,75,76,77:
			alert("lotteryCommonInit");
		default:
	}
	if(cpbm==51 || cpbm==52 || cpbm==53 || cpbm==54 || cpbm ==55 || cpbm == 56 || 
			cpbm==57 || cpbm==58 || cpbm==59 || cpbm==60 || cpbm==61 || cpbm==62 || cpbm==63|| cpbm==75 || cpbm==76 || cpbm==77 || cpbm==90 || cpbm==91){
		lotteryBtn();// 彩票按钮初始化
		lotteryPage();// 彩种页面
		// 金额位置下拉
		var istrue = true;
		$("#right-ye").on("click", function() {
			istrue = !istrue;
			$("#right-xs").css("display", istrue ? "none" : "block");
		});
	
		$("#container").click(function() {
			$("#right-xs").css("display", "none");
			istrue = true;
		});
		// 金额位置下拉后点击变色
		$(".pop-setting1 li").on("touchstart click", function() {
			$(".pop-setting1 li").removeClass("color-br-gray");
			$(this).addClass("color-br-gray");
		});
		// 游戏规则弹框
		$('#yxgz').on('click', function() {
// guize_box();
			wfgzfn(cpbm,1);
		});
		// 监听冒泡
		var gz = $(".belt_shuoming");
		for(var i=0;i<gz.length;i++){
			gz[i].addEventListener('click',function(event){
				event.stopPropagation();
			},true);
		}	
	}else{
		if(lotteryObj[cpbm]=='' || lotteryObj[cpbm] == undefined){
			getSscTextWf3(cpbm);
		}else{
			$(".content_lc").html(lotteryObj[cpbm]);
			initButtonWf3Text(); // 选择下注项
		}
		
		getHyje();// 得到金额
	
		lotteryPage();// 彩种页面
	
		lotteryBtn();// 彩票按钮初始化
	
		// 金额位置下拉
		var istrue = true;
		$("#right-ye").on("click", function() {
			istrue = !istrue;
			$("#right-xs").css("display", istrue ? "none" : "block");
		});
	
		$("#container").click(function() {
			$("#right-xs").css("display", "none");
			istrue = true;
		});
		// 金额位置下拉后点击变色
		$(".pop-setting1 li").on("touchstart click", function() {
			$(".pop-setting1 li").removeClass("color-br-gray");
			$(this).addClass("color-br-gray");
		});
	
		// 游戏规则弹框
		$('#yxgz').on('click', function() {
			three();
		});
		function three() {
			layer.open({
				type : 1,
				skin : "role_btn1",
				title : '游戏规则',
				area : '90%',
				btn : "确定",
				shadeClose : true,
				content : $("#guize_box")
			});
		}
	
		// tab切换==玩法1切换
		$(".scroll ul li").click(function() {
			var flag = $(this).attr("isactives");
			if (flag == 1) {
	    		var a = $("#cpbm").val();
	    		if(a==46){
	    			$(".row .bet").removeClass("bet-choose");
	    			$(".smallround").removeClass("menus-choose");
	    			$(".addMoney_contain").hide();
	    		}
				$(this).addClass('active').siblings().removeClass('active');
				var index = $(this).index();
				number = index;
				$('.content_lc .bet-view').hide();
				$('.content_lc .bet-view:eq(' + index + ')').show();
			} else {
				layer.alert("此玩法在维护中……请选择其它玩法");
			}
		});
		
		getFjKjhm(cpbm);// 获得开奖号码
		
	    $(".Collapsing_one").click(function () {// 下拉
	        $(this).toggleClass("current_one").siblings('.Collapsing_one').removeClass("current_one");// 切换图标
	        $(this).next(".coll_body").slideToggle(500).siblings(".coll_body").slideUp(500);
	    });
	    
		if(chips_str!=""){
			$("#chipshwb").html(chips_str);
		}
	
		chipSz();// 筹码设置
	
		showChip();// 筹码选择
	
		chipFz();// 筹码付值
		// 清空
		$(".button-clear").on("click", function() {
			clearData();
		});
	
		betBtn();// 下注
	}
}


function guize_box() {
	layer.open({
		type : 1,
		skin : "role_btn1",
		title : '游戏规则',
		area : '90%',
		btn : "确定",
		shadeClose : true,
		content : $("#guize_box")
	});
}
/**
 * 彩种页面
 */
function lotteryPage() {
	$('#J_reorder').on('click', function() {
		layer.open({
			type : 1,
			skin : "role_btn16",
			title : '彩票分类',
			area : '100%',
			btn : "关闭",
			shadeClose : true,
			closeBtn : 0, // 不显示关闭按钮
			content : $("#J_pop_setting")
		});
	});
}

/*
 * 个人盈亏
 */
function getGryk() {
	var index = load_open();
	$.ajax({
		url : "lottery/gryk.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			load_close(index);
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "4") {
				$("#gryk div").html(data.message);
				layer.open({
					type : 1,
					skin : "role_btn5",
					title : '个人盈亏',
					area : [ '320px', '400px' ],
					shadeClose : true,
					content : $("#gryk")
				});
			}

		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function getGrykUl(hybm) {
	var i = load_open();
	$.ajax({
		url : "lottery/grykul.do",
		type : "POST",
		data : {
			grykkssj : $("#grykkssj").val(),
			grykjssj : $("#grykjssj").val(),
			hybm : hybm
		},
		dataType : "json",
		success : function(data) {
			layer.close(i);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "4") {
				$("#grykContent").html(data.message);
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

// 清空数据
function clearData() {
	$(".row .bet").removeClass("bet-choose");
	// $("#doc-ipt-email-1").val(1);
	$(".smallround").removeClass("menus-choose");
	$(".box_zs").html(0);
	$(".pm-body .lottery-ball").removeClass("solid");
	$(".addMoney_contain").hide();
	
	// 房间移除
	$(".bet-daxiao div").removeClass("ds_ball");
	$(".bet_number_box div").removeClass("ds_ball");
	
}

/**
 * 筹码设置
 */
function chipSz() {
	$('#chip_btn').on('click',function() {
				layer.open({
					type : 1,
					skin : "role_btn1",
					title : '请选择1~3个筹码',
					area : [ '270', '227' ],
					shadeClose : true,
					content : $("#chip-model"),
					btn : "确定",
					yes : function(index) {
						$("#chipshwb").empty();
						$("#chipshwb").append(
							   $(".am-modal-bd .ng-scope .chip_choosed").parent()[0].outerHTML).append(
								$(".am-modal-bd .ng-scope .chip_choosed").parent()[1].outerHTML).append(
								$(".am-modal-bd .ng-scope .chip_choosed").parent()[2].outerHTML);
						chipFz();
						layer.close(index);
						
						chips_str = $("#chipshwb").html();
					}
				});
			});
}

/**
 * 筹码选择
 */
function showChip() {
	$(".am-modal-bd .ng-scope .chip").unbind("click").bind("click", function() {
		var cm = $(".chip-hide").size();
		if (cm <= 7 && $(this).hasClass('chip-hide')) {
			$(".chip_choosed").eq(3).toggleClass("chip_choosed chip-hide");
			$(this).toggleClass("chip_choosed chip-hide");
		} else {
			$(this).toggleClass("chip_choosed chip-hide");
		}
	});
}
/**
 * 筹码付值
 */
function chipFz() {
	// 筹码付值
	$("#chipshwb .chip_choosed").on("click", function() {
		var chip = $(this).attr("chips-data");
		$("#doc-ipt-email-1").val(Number(chip));
		cj_money = $("#doc-ipt-email-1").val();// 全局money
	});
}
/**
 * 下注
 */
function betBtn() {
	$('#doc-prompt-toggle')
			.click(
					function() {
						localArray = [];
						var money = Number($("#doc-ipt-email-1").val());
						// alert(money);
						if (money <= 0) {
							layer.alert("请输入下注金额");
							return false;
						}
						if ($(".bet-choose").length <= 0) {
							layer.alert('请选择您要下注的选项');
							return false;
						}
						var pourList = '';
						var pourCount = 0;
						var cpbm = $("#cpbm").val();
						if (cpbm == 20 || cpbm == 21 || cpbm == 22
								|| cpbm == 23 || cpbm == 43 || cpbm == 44 || cpbm==61 || cpbm==66 || cpbm==67 || cpbm==68 || cpbm==69 || cpbm==70 ||cpbm==71) {
							$(".bet-choose")
									.each(
											function() {
												var title = $(this).attr(
														"title");
												var odds = $(this).find(
														".bet-item").html();
												var item = $(this).find(
														".bet-content").html();
												pourCount++;
												var localData = new Object();
												localData.wfmc2 = $(this).attr("title");
												localData.wfmc3 = $(this).find(".bet-content").attr("title");
												localData.wfbm3 = $(this).find(".bet-item").attr("id");
												localData.pl = $(this).find(".bet-item").html();
												localData.tzhm = $(this).find(".bet-content").attr("title");
												localData.zs = 1;
												localData.price = $(this).find(".addMoney_money").html();
												localData.cpqh = $(".curIssueNumberId").html();
												localArray.push(localData);
											});
						} else if(cpbm == 55 ||cpbm==75 || cpbm==76 || cpbm==77){
							$(".bet-choose").each(function() {
										var title = $(this).attr("title");
										var odds = $(this).find(".bet-item").html();
										var item = $(this).find(".bet-content").html();
										pourCount++;
										var localData = new Object();
// localData.wfmc2 = $(this).attr("title");
										localData.wfmc3 = $(this).attr("title")+"-"+$(this).find(".bet-content").html();
										localData.wfbm3 = $(this).find(".bet-item").attr("id");
										localData.hm = "";
										localData.money = $(this).find(".addMoney_money").html();
										var a = localData.wfbm3;
										var wfbm3 = a.substring(a.length-4,a.length);
										switch (wfbm3) {
										case '1001':
										case '1002':
										case '1003':
										case '1101':
										case '1102':
										case '1103':
										case '1204':
										case '1205':
										case '1206':
										case '1207':
										case '1301':
										case '1302':
										case '1303':
										case '1304':
										case '1401':
										case '1402':
										case '1403':
										case '1404':
										case '1405':
										case '1406':
										case '1407':
										case '1408':
										case '1409':
										case '1410':
										case '1411':
											if ($("#box" + wfbm3).find(
													".solid").length > 0) {
												var str = "";
												var num = 0;
												var len = $(
														"#box" + wfbm3)
														.find(".solid").length;
												$("#box" + wfbm3)
														.find(".solid")
														.each(
																function() {
																	num++;
																	if (len == num) {
																		str += $(
																				this)
																				.html();
																	} else {
																		str += $(
																				this)
																				.html()
																				+ ",";
																	}
																});
												localData.hm = str;
											}
											localData.pl = $(this).find(".bet-item").html();
											localData.tzhm = $(this).find(".bet-content").html();
											localData.zs = $("#box" + wfbm3).find(".box_zs").html();
											localData.price = money;
											localData.cpqh = $(".curIssueNumberId").html();
											localArray.push(localData);
											break;
										default:
											localData.pl = $(this).find(".bet-item").html();
											localData.tzhm = $(this).find(".bet-content").html();
											localData.zs = 1;
											localData.price = localData.money;
											localData.cpqh = $(".curIssueNumberId").html();
											localArray.push(localData);
											break;
										}
									});
						}else {
							$(".bet-choose")
									.each(
											function() {
												var title = $(this).attr(
														"title");
												var odds = $(this).find(
														".bet-item").html();
												var item = $(this).find(
														".bet-content").html();
												pourCount++;
												var localData = new Object();
												localData.wfmc2 = $(this).attr(
														"title");
												localData.wfmc3 = $(this).find(
														".bet-content").html();
												localData.wfbm3 = $(this).find(
														".bet-item").attr("id");
												localData.hm = "";
												localData.money = $(this).find(
														".addMoney_money")
														.html();
												var wfbm3 = localData.wfbm3;
												switch (wfbm3) {
												case '401101001':
												case '401101002':
												case '401101003':
												case '401201001':
												case '401201002':
												case '401201003':
												case '401301001':
												case '401301002':
												case '401301003':
												case '401301004':
												case '401401001':
												case '401401002':
												case '401401003':
												case '401401004':
												case '401501001':
												case '401501002':
												case '401501003':
												case '401501004':
												case '401501005':
												case '401501006':
												case '401501007':
												case '401501008':
												case '401501009':
												case '401501010':
												case '401501011':
													if ($("#box" + wfbm3).find(
															".solid").length > 0) {
														var str = "";
														var num = 0;
														var len = $(
																"#box" + wfbm3)
																.find(".solid").length;
														$("#box" + wfbm3)
																.find(".solid")
																.each(
																		function() {
																			num++;
																			if (len == num) {
																				str += $(
																						this)
																						.html();
																			} else {
																				str += $(
																						this)
																						.html()
																						+ ",";
																			}
																		});
														localData.hm = str;
													}
													localData.pl = $(this)
															.find(".bet-item")
															.html();
													localData.tzhm = $(this)
															.find(
																	".bet-content")
															.html();
													localData.zs = $(
															"#box" + wfbm3)
															.find(".box_zs")
															.html();
													localData.price = money;
													localArray.push(localData);
													break;
												default:
													localData.pl = $(this)
															.find(".bet-item")
															.html();
													localData.tzhm = $(this)
															.find(
																	".bet-content")
															.html();
													localData.zs = 1;
													localData.price = localData.money;
													localData.cpqh = $(".curIssueNumberId").html();
													localArray.push(localData);
													break;
												}
											});
						}
						layerOpenBox(localArray);
					});
}

/**
 * 彩票提交内容
 * 
 * @param localArray
 * @returns {String}
 */
function contentfn(localArray) {
	var zhzje = Number($("#zhzje").html());
	var temp = "<table><thead><tr></th><th width='40%'></th><th width='20%'></th><th width='25%'></th><th width='12%'></th></tr></thead><tbody>";
	var allM = 0;
	var zzs = 0;
	var price = 0;
	$.each(
					localArray,
					function(index, item) {
						if (!isNaN(item.price) && item.price != 0
								&& item.price != "") {
							price = item.price;
							allM += Number(item.zs) * Number(item.price);
							zzs += Number(item.zs);
						}
						if(item.wfmc2 == undefined){
							wfmc2 = "";
						}else{
							wfmc2 = item.wfmc2+"-";
						}
						temp += "<tr>";
						temp += "<td>"
								+ wfmc2
								+ item.wfmc3
								+ "</td><td><strong class='red'>"
								+ item.pl
								+ "*1</strong></td><td><input type='number' style='font-size:13px;padding:0;' onkeydown='return onlyNumber(event,this);' onkeyup='updatePirce(this.value,"
								+ index
								+ ");' maxlength='6' value='"
								+ price
								+ "'></td><td><a href='javascript:;' onclick='deleteDate("
								+ index + ")'>删除</a></td>";
						temp += '</tr>';
					});
	temp += "</tbody></table>";
	var cpbm = $("#cpbm").val();
	if(cpbm==46){
		if (allM > zhzje) {
			temp += "<div class='tzdhk_box' style='padding:0 10px;'><div>第<strong class='red'>刮刮彩</strong>&nbsp;&nbsp;&nbsp;&nbsp;注数：<strong class='red' id='infoLength'>"
					+ zzs
					+ "</strong>&nbsp;&nbsp;&nbsp;&nbsp;<span>总金额：<strong class='red' id='allM'>"
					+ allM
					+ "</strong><br/><span class='notMoney' style='color:#3c763d'>(余额不足，当前余额为<strong class='red refreshM'>"
					+ zhzje
					+ "</strong><i class='img-login-refresh icon'></i>,请前往<a href='javascript:javascript:getCztx();' style='color:red;text-decoration:underline'>充值</a>)</span></span></div></div>";
		} else {
			temp += "<div class='tzdhk_box' style='padding:0 10px;'><div><strong class='red'>刮刮彩</strong>&nbsp;&nbsp;&nbsp;&nbsp;注数：<strong class='red' id='infoLength'>"
				+ zzs
				+ "</strong>&nbsp;&nbsp;&nbsp;&nbsp;<span>总金额：<strong class='red' id='allM'>"
				+ allM + "</strong></div></div>";
		}
	}else{
		if (allM > zhzje) {
			temp += "<div class='tzdhk_box' style='padding:0 10px;'><div>第<strong class='red'>"
					+ $(".curIssueNumberId").html()
					+ "</strong>期&nbsp;&nbsp;&nbsp;&nbsp;注数：<strong class='red' id='infoLength'>"
					+ zzs
					+ "</strong>&nbsp;&nbsp;&nbsp;&nbsp;<span>总金额：<strong class='red' id='allM'>"
					+ allM
					+ "</strong><br/><span class='notMoney' style='color:#3c763d'>(余额不足，当前余额为<strong class='red refreshM'>"
					+ zhzje
					+ "</strong><i class='img-login-refresh icon'></i>,请前往<a href='javascript:javascript:getCztx();' style='color:red;text-decoration:underline'>充值</a>)</span></span></div></div>";
		} else {
				temp += "<div class='tzdhk_box' style='padding:0 10px;'><div>第<strong class='red'>"
					+ $(".curIssueNumberId").html()
					+ "</strong>期&nbsp;&nbsp;&nbsp;&nbsp;注数：<strong class='red' id='infoLength'>"
					+ zzs
					+ "</strong>&nbsp;&nbsp;&nbsp;&nbsp;<span>总金额：<strong class='red' id='allM'>"
					+ allM + "</strong></div></div>";
		}
	}
	
	return temp;
}

/**
 * 输入数字
 */
function onlyNumber(e, t) {
	var code = null;
	// 只能输入数字
	// if($.browser.msie){
	// code = event.keyCode;
	// }else{
	code = e.which;
	// }
	// 48 - 57 上排数字键 96 - 105 数字键盘 8 删除键
	// if (((code > 47) && (code < 58)) || (code >= 96 && code <= 105) ||
	// code==8 || /^[0-9]+$/.test(t)) {
	// return true;
	// } else {
	// return false;
	// }
}

function updatePirce(a, b) {
	localArray[b].price = a;
	var zzs = 0;
	var allM = 0;
	$.each(localArray, function(index, item) {
		if (!isNaN(item.price) && item.price != 0 && item.price != "") {
			price = item.price;
			allM += Number(item.zs) * Number(item.price);
			zzs += Number(item.zs);
		}
	});
	$("#infoLength").empty();
	$("#infoLength").append(zzs);
	$("#allM").empty();
	$("#allM").append(allM);
}
// 删除投注
function deleteDate(index) {
	localArray.splice(index, 1);
	if (localArray.length <= 0) {
		layer.closeAll();
	} else {
		$("#model_body").empty();
		$("#model_body").append(contentfn(localArray));
	}
}
// 投注明细
function layerOpenBox(localArray) {
	var content = contentfn(localArray);
	layer.open({
		type : 1, // page层
		skin : "role_btn1",
		area : '90%',
		title : '下注明细(请确认注单)',
		shade : 0.6, // 遮罩透明度
		scrollbar : false,
		moveType : 0, // 拖拽风格，0是默认，1是传统拖动
		shift : 1, // 0-6的动画形式，-1不开启
		content : "<div id='model_body'>" + content + "</div>",
		btn : [ '确定', '取消' ],
		yes : function(index) {
			var flag = true;
			var cpbm = $("#cpbm").val();
			if(cpbm==46){
    			flag = submitfnxt(index,localArray,flag);
    		}else{
    			flag = submitfn(index, localArray, flag);
    		}
			if (flag || flag == undefined) {
				localArray = [];
				clearData();
			}
		},
		btn2 : function(index) {
			layer.close(index);
			localArray = [];
			clearData();
		},
		cancel : function(index) {
			layer.close(index);
			localArray = [];
			clearData();
		}
	});
}
// 提交
function submitfn(layerindex, localArray, flag) {
	var tzzje = 0;
	var cpbm = $("#cpbm").val();
	var fjmoney = $("#fjmoney").val();
	$.each(localArray, function(index, item) {
		if (isNaN(item.price) || item.price <= 0 || item.price == ""
				|| !(/^[0-9]+$/.test(item.price))) {
			layer.alert("金额输入有错误,只能整数，请重新输入");
			flag = false;
			return false;
		} else {
			tzzje += Number(item.zs) * Number(item.price);
		}
		if(cpbm==51 || cpbm ==52 || cpbm==53 || cpbm ==54  || cpbm ==55 || cpbm == 56 || 
				cpbm==57 || cpbm==58 || cpbm==59 || cpbm==60 || cpbm==61 || cpbm==62 || cpbm==75 || cpbm==76 || cpbm==77 || cpbm==90 || cpbm==91){
			if(Number(item.price)<Number(fjmoney)){
				layer.alert("投注金额 不能小于房间的最小金额");
				flag = false;
				return false;
			}
		}
	});
	if (!flag) {
		return false;
	}
	var zhzje = $("#zhzje").text();
	if (tzzje > zhzje) {
		layer.alert("金额不足！！");
		return false;
	}
	var cpqh = $(".curIssueNumberId").html();
	var wfbm1 = $("#wfbm1").val();
	if(wfbm1==undefined || wfbm1==''){
		wfbm1="10000";
	}
	var jsonrow = JSON.stringify(localArray);
	load_open();
	var encrypt = new JSEncrypt();
	encrypt.setPublicKey(PUBLIC_KEY);
	$.ajax({
		url : "lottery11/s1av11e.do",
		type : "POST",
		timeout :timeouttime,
		data : {
			"jsonrow" : base64encode(encodeURIComponent(jsonrow)),
			"tzzje" : encrypt.encrypt(tzzje.toString()),
			"cpbm" : encrypt.encrypt(cpbm),
			"cpqh" : encrypt.encrypt(cpqh),
			"wfbm1": encrypt.encrypt(wfbm1)
		},
		success : function(json) {
			load_closeAll();
			if(json==-1000){
				tisAlert();
				return;
			}
			if (json == 1) {
				getHyje();// 得到会员金额
				
				if(cpbm==51 || cpbm ==52 || cpbm ==53 || cpbm ==54  || cpbm ==55 || cpbm == 56 || 
						cpbm==57 || cpbm==58 || cpbm==59 || cpbm==60 || cpbm==61 || cpbm==62 || cpbm==75 || cpbm==76 || cpbm==77 || cpbm==90 || cpbm==91){
					// sendMessageWithChatRoom("chat",localArray);
				}else{
					div_tzcg();
				}
				showWDXZ();
			} else if (json == 2) {
				layer.alert("封盘中……，请耐心等待");// 投注还没开始，请耐心等待
			} else if (json == 3) {
				layer.alert("投注失败！！期号错误，请跟管理员联系！");// 投注失败！！期号错误，请跟管理员联系！
			} else if (json == 4) {
				layer.alert("非法号码！");
			} else if (json == 6) {
				layer.alert("投注超限，请减少投注号码！");
			} else if (json == 7) {
				layer.alert("投注失败");
			} else if (json == 8) {
				getloginpage();
			} else if (json == 9) {
				layer.alert("金额错误，请与管理员联系！");
			}else if (json == 10) {
				layer.alert("数据加密错误，请关机重新启动系统.如再出现些问题，请联系管理员");
			}else if (json == 11) {
				layer.alert("提交过于频繁");
			}else if(json==12){
				layer.alert("不符合本期投注规则，不能同时投注[大,小]");
			}else if(json==13){
				layer.alert("不符合本期投注规则，不能同时投注[单,双]");
			}else if(json==14){
				layer.alert("不符合本期投注规则，不能同时投注[大单,大双,小单,小双]");
			}else if(json==15){
				getloginpage();
			}else if(json==16){
				index();
				layer.alert("此彩种维护中。。。请选择其它彩种");
			}else {
				layer.alert("投注错误，重新刷新或与管理员联系");
			}
			return true;
		},
		error : function(x, h, e) {
			load_closeAll();
		},
		complete: function (XMLHttpRequest, status) { // 当请求完成时调用函数
	        if (status == 'timeout') {// status ==
										// 'timeout'意为超时,status的可能取值：success,notmodified,nocontent,error,timeout,abort,parsererror
				layer.alert("返回结果超时,请到已下注明细查询是否下注成功!");
				getHyje();
	    	}
		}
	});
}


// 提交
function submitfnxt(layerindex, localArray, flag) {
	var tzzje = 0;
	$.each(localArray, function(index, item) {
		if (isNaN(item.price) || item.price <= 0 || item.price == ""
				|| !(/^[0-9]+$/.test(item.price))) {
			layer.alert("金额输入有错误,只能整数，请重新输入");
			flag = false;
		} else {
			tzzje += Number(item.zs) * Number(item.price);
		}
	});
	if (!flag) {
		return false;
	}
	var zhzje = $("#zhzje").text();
	if (tzzje > zhzje) {
		layer.alert("金额不足！！");
		return false;
	}
	var cpqh = $(".curIssueNumberId").html();
	var cpbm = $("#cpbm").val();
	var wfbm1 = $("#wfbm1").val();
	if(wfbm1==undefined || wfbm1==''){
		wfbm1="10000";
	}
	var jsonrow = JSON.stringify(localArray);
		var encrypt = new JSEncrypt();
	encrypt.setPublicKey(PUBLIC_KEY);
	console.log(jsonrow)
	console.log(cpqh)
	console.log(cpbm)
	console.log(wfbm1)
	console.log(encrypt.encrypt(tzzje.toString()))
	console.log(encrypt.encrypt(cpbm))
	console.log( encrypt.encrypt(cpqh))
	console.log(encrypt.encrypt(wfbm1))


//	load_open();

//	$.ajax({
//		url : "ggc/save.do",
//		type : "POST",
//		timeout : timeouttime,
//		data : {
//			"jsonrow" : base64encode(encodeURIComponent(jsonrow)),
//			"tzzje" : encrypt.encrypt(tzzje.toString()),
//			"cpbm" : encrypt.encrypt(cpbm),
//			"cpqh" : encrypt.encrypt(cpqh),
//			"wfbm1": encrypt.encrypt(wfbm1)
//		},
//		success : function(json) {
//			load_closeAll();
//			if(json==-1000){
//				tisAlert();
//				return;
//			}
//			if(isNaN(json)){
//				 div_ggc(json);
//				 showWDXZ();
//			}else{
//				if (json == 2) {
//					layer.alert("封盘中……，请耐心等待");// 投注还没开始，请耐心等待
//				} else if (json == 3) {
//					layer.alert("投注失败！！期号错误，请跟管理员联系！");// 投注失败！！期号错误，请跟管理员联系！
//				} else if (json == 4) {
//					layer.alert("非法号码！");
//				} else if (json == 6) {
//					layer.alert("投注超限，请减少投注号码！");
//				} else if (json == 7) {
//					layer.alert("投注失败");
//				} else if (json == 8) {
//					getloginpage();
//				} else if (json == 9) {
//					layer.alert("金额错误，请与管理员联系！");
//				}else if (json == 10) {
//					layer.alert("数据加密错误，请关机重新启动系统.如再出现些问题，请联系管理员");
//				}else if (json == 11) {
//					layer.alert("提交过于频繁");
//				}else if(json==12){
//					layer.alert("不符合本期投注规则，不能同时投注[大,小]");
//				}else if(json==13){
//					layer.alert("不符合本期投注规则，不能同时投注[单,双]");
//				}else if(json==15){
//					getloginpage();
//				}else if(json==16){
//					index();
//					layer.alert("此彩种维护中。。。请选择其它彩种");
//				}else {
//					layer.alert("投注错误，重新刷新或与管理员联系");
//				}
//			}
//			return true;
//		},
//		error : function(x, h, e) {
//			load_closeAll();
//		},
//		complete: function (XMLHttpRequest, status) { // 当请求完成时调用函数
//	        if (status == 'timeout') {// status ==
//										// 'timeout'意为超时,status的可能取值：success,notmodified,nocontent,error,timeout,abort,parsererror
//		          layer.alert("返回结果超时,请到已下注明细查询是否下注成功!");
//		          getHyje();
//	    	}
//		}
//	});
}


/**
 * 投注成功弹出层
 */
function div_tzcg() {
	layer.open({
		type : 1,
		skin : "role_btn2",
		title : '提醒',
		area : [ '85%' ],
		shadeClose : true,
		content : $("#tjcg"),
		time : 500
	});
}

/**
 * 彩票数据初始化（期号、时间、开奖号码）
 */
function lotteryDateInit() {
	var cpbm = $("#cpbm").val();
	if(cpbm!=51 && cpbm!=52 && cpbm!=53 && cpbm!=54){
		getCpqhAndTime(cpbm);
	}
}

function setCpqhKjhm(message) {
	var messages = message.split("|");
	$(".per-period").html(messages[1] + "期");
	var obj = messages[2].split(",");
	var str = '';
	var cpbm = $("#cpbm").val();
	if (cpbm == 17 || cpbm == 18 || cpbm == 19 || cpbm==47 || cpbm==49 || cpbm==50) {
		var sum = Number(obj[0])+Number(obj[1])+Number(obj[2])+Number(obj[3])+Number(obj[4]);
		str = "<span class='round data-" + obj[0] + "'>" + obj[0] + "</span>"
				+ "<span class='round data-" + obj[1] + "'>" + obj[1]
				+ "</span>" + "<span class='round data-" + obj[2] + "'>"
				+ obj[2] + "</span>" + "<span class='round data-" + obj[3]
				+ "'>" + obj[3] + "</span>" + "<span class='round data-"
				+ obj[4] + "'>" + obj[4] + "</span>"
				+"<span style='color:black;background:none;border-radius:unset;margin-right:unset;'>=</span>"
				+"<span style='background:red;margin-right:unset;width:26px;height:26px;line-height:26px;font-size:15px;'>"+sum+"</span>"
				+"<span style='width:10px;color:black;background:none;border-radius:unset;margin-right:unset;'>(</span>"
				+"<span style='width:15px;height:15px;margin-right:unset;background:none;"+(sum>22?'color:red':'color:blue')+";'>"+(sum>22?'大':'小')+"</span>&nbsp"
				+"<span style='width:15px;height:15px;margin-right:unset;background:none;"+(sum%2==0?'color:red':'color:blue')+";'>"+(sum%2==0?'双':'单')+"</span>"
				+"<span style='width:10px;color:black;background:none;border-radius:unset;margin-right:unset;'>)</span>";
	} else if (cpbm == 20 || cpbm == 21 || cpbm == 22 || cpbm == 23
			|| cpbm == 43 || cpbm == 44 || cpbm == 70 || cpbm == 71) {
		var sum = Number(obj[0])+Number(obj[1])+Number(obj[2]);
		str = "<span class='round-20 data-" + obj[0] + "'>" + obj[0]
				+ "</span>" + "<span class='round-20 data-" + obj[1] + "'>"
				+ obj[1] + "</span>" + "<span class='round-20 data-" + obj[2]
				+ "'>" + obj[2] + "</span>"
				+"<span style='color:black;background:none;border-radius:unset;margin-right:unset;'>=</span>"
				+"<span style='background:red;margin-right:unset;width:26px;height:26px;line-height:26px;font-size:15px;'>"+sum+"</span>"
				+"<span style='width:10px;color:black;background:none;border-radius:unset;margin-right:unset;'>(</span>"
				+"<span style='width:15px;height:15px;margin-right:unset;background:none;color:blue;'>"+(sum>10?'大':'小')+"</span>&nbsp"
				+"<span style='width:15px;height:15px;margin-right:unset;background:none;color:red;'>"+(sum%2==0?'双':'单')+"</span>"
				+"<span style='width:10px;color:black;background:none;border-radius:unset;margin-right:unset;'>)</span>";
	} else if (cpbm == 37 || cpbm == 42) {
		str = "<span class='round-6 data-" + obj[0] + "'>" + obj[0] + "</span>"
				+ "<span class='round-6 data-" + obj[1] + "'>" + obj[1]
				+ "</span>" + "<span class='round-6 data-" + obj[2] + "'>"
				+ obj[2] + "</span>" + "<span class='round-6 data-" + obj[3]
				+ "'>" + obj[3] + "</span>" + "<span class='round-6 data-"
				+ obj[4] + "'>" + obj[4] + "</span>"
				+ "<span class='round-6 data-" + obj[5] + "'>" + obj[5]
				+ "</span>" + "<span class='round-6 data-" + obj[6] + "'>"
				+ obj[6] + "</span>" + "<span class='round-6 data-" + obj[7]
				+ "'>" + obj[7] + "</span>" + "<span class='round-6 data-"
				+ obj[8] + "'>" + obj[8] + "</span>"
				+ "<span class='round-6 data-" + obj[9] + "'>" + obj[9]
				+ "</span>";
	} else if (cpbm == 39) {
		str = "<span class='round data-" + obj[0] + "'>" + obj[0] + "</span>"
				+ "<span class='round data-" + obj[1] + "'>" + obj[1]
				+ "</span>" + "<span class='round data-" + obj[2] + "'>"
				+ obj[2] + "</span>" + "<span class='round data-" + obj[3]
				+ "'>" + obj[3] + "</span>" + "<span class='round data-"
				+ obj[4] + "'>" + obj[4] + "</span>"
				+ "<span class='round data-" + obj[5] + "'>" + obj[5]
				+ "</span>" + "<span class='round data-" + obj[6] + "'>"
				+ obj[6] + "</span>" + "<span class='round data-" + obj[7]
				+ "'>" + obj[7] + "</span>";
	} else if (cpbm == 41 || cpbm == 45) {
		str = "<span class='round data-1'>" + obj[0] + "</span>"
				+ "<span class='round data-1'>" + obj[1] + "</span>"
				+ "<span class='round data-1'>" + obj[2] + "</span>"
				+ "<span class='round data-none'>=</span>"
				+ "<span class='round data-1'>"
				+ (Number(obj[0]) + Number(obj[1]) + Number(obj[2]))
				+ "</span>";
	}
	getFjKjhm(cpbm);
	$("#result-balls").html(str);
}


/**
 * 得到开奖记录
 * 
 * @param cpbm
 */
function getKjhmList(cpbm) {
	$.ajax({
		url : "lottery/findKjhmNoPage.do",
		data : {
			"cpbm" : cpbm
		},
		type : "POST",
		dataType : "html",
		success : function(data) {
			$(".kj_box").html(data);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
};

/**
 * 得到彩票玩法3文本
 */
function getSscTextWf3(cpbm) {
	var index1 = load_open();
	$.ajax({
		url : "lottery/getSscTextWf3.do",
		type : "POST",
		timeout : timeouttime,
		data : {
			"cpbm" : cpbm
		},
		success : function(data) {
			load_close(index1);
			lotteryObj[cpbm] = data;
			$(".content_lc").html(data);
			initButtonWf3Text(); // 选择下注项
		},
		error : function(x, h, e) {
			load_closeAll();
		},
		complete: function (XMLHttpRequest, status) { // 当请求完成时调用函数
	        if (status == 'timeout') {// status ==
										// 'timeout'意为超时,status的可能取值：success,notmodified,nocontent,error,timeout,abort,parsererror
	        	getSscTextWf3(cpbm);
	    	}
		}
	});
}

function initButtonWf3Text() {
	var cpbm = $("#cpbm").val();
	if (cpbm == 40) {
		lhcButtonInit();// 六合彩按钮初始化
	} else if(cpbm==55 || cpbm==75 || cpbm==76 || cpbm==77){
		jsLhcButtonInit();
	}else {
		$(".addMoney_delete").click(function(e) {
							e.stopPropagation();
							$(this).parents(".bet").removeClass("bet-choose");
							$(this).parents(".addMoney_contain").hide();
							var _index = $(this).parents(".bet-view").attr(
									"data-index");
							$(this).parents(".bet-view").find(".bet-choose").length > 0 ? $(
									".smallround:eq(" + _index + ")").addClass(
									"menus-choose")
									: $(".smallround:eq(" + _index + ")")
											.removeClass("menus-choose");
						});
		// 选择下注项
		$(".lottery-bet11 .row .bet")
				.click(
						function() {
							var _index = $(this).parents(".bet-view").attr(
									"data-index");
							var flag = $(".smallround:eq(" + _index + ")")
									.parents(".nav").attr("isactives");
							if (flag == 1) {
								var money = $("#doc-ipt-email-1").val();
								if (Number(money) == NaN || Number(money) <= 0
										|| !/^[0-9]+$/.test(money)) {
									layer.alert("请先选择金额，金额是整数");
									return;
								}
								$(this).addClass("bet-choose");
								$(".pour-num").html(
										$(".bet-choose").length <= 0 ? 0
												: $(".bet-choose").length);
								$(this).parents(".bet-view")
										.find(".bet-choose").length > 0 ? $(
										".smallround:eq(" + _index + ")")
										.addClass("menus-choose") : $(
										".smallround:eq(" + _index + ")")
										.removeClass("menus-choose");
								var operation = $(this).find(
										".addMoney_contain").css("display");
								if (operation == "block") {
									$(this).find(".addMoney_money").html(
											parseInt($(this).find(
													".addMoney_money").html())
													+ Number(money));
								} else {
									$(this).find(".addMoney_money").html(
											Number(money));
									$(this).find(".addMoney_contain").show();
								}
							} else {
								layer.alert("此类玩法正在维护中……。请选择其它玩法");
							}

						});
	}
}

// ////////////////////////////////////六合彩////////////////////////////////////////////////////

// 递归函数
function f(n) {
	if (n <= 1) {
		return 1;
	} else {
		return n * f(n - 1);
	}
}
/**
 * 六合彩按钮初始化
 */
function lhcButtonInit() {
	$(".addMoney_delete")
			.click(
					function(e) {
						e.stopPropagation();
						$(this).parents(".bet").removeClass("bet-choose");
						$(this).parents(".addMoney_contain").hide();
						var _index = $(this).parents(".bet-view").attr(
								"data-index");
						$(this).parents(".bet-view").find(".bet-choose").length > 0 ? $(
								".smallround:eq(" + _index + ")").addClass(
								"menus-choose")
								: $(".smallround:eq(" + _index + ")")
										.removeClass("menus-choose");
					});
	$('.lottery-bet11 .row .bet')
			.on(
					'click',
					function() {
						var money = $("#doc-ipt-email-1").val();
						if (Number(money) == NaN || Number(money) <= 0
								|| !/^[0-9]+$/.test(money)) {
							layer.alert("请先选择金额，金额是整数");
							return;
						}
						$(this).addClass("bet-choose");
						var _index = $(this).parents(".bet-view").attr(
								"data-index");
						var flag = $(".smallround:eq(" + _index + ")").parents(
								".nav").attr("isactives");
						if (flag == 1) {
							var wfbm3 = $(this).find(".bet-item").attr("id");
							switch (wfbm3) {
							case '401101001':
							case '401101002':
							case '401101003':
							case '401201001':
							case '401201002':
							case '401201003':
							case '401301001':
							case '401301002':
							case '401301003':
							case '401301004':
							case '401401001':
							case '401401002':
							case '401401003':
							case '401401004':
							case '401501001':
							case '401501002':
							case '401501003':
							case '401501004':
							case '401501005':
							case '401501006':
							case '401501007':
							case '401501008':
							case '401501009':
							case '401501010':
							case '401501011':
								box(wfbm3);
								var wfpl2 = $(this).find(".bet-item").attr(
										"wfpl2");
								$("#box" + wfbm3).parents(".role_btn10").find(
										".box_pl").html(wfpl2);
								var b = $("#box" + wfbm3)
										.parents(".role_btn10").find(".box_zs")
										.html();
								if (b == 0) {
									$("#box" + wfbm3)
											.parents(".role_btn10")
											.find(
													".layui-layer-btn .layui-layer-btn0")
											.addClass("buttoncolor");
								} else {
									$("#box" + wfbm3)
											.parents(".role_btn10")
											.find(
													".layui-layer-btn .layui-layer-btn0")
											.removeClass("buttoncolor");
								}
								break;
							default:
								$(".pour-num").html(
										$(".bet-choose").length <= 0 ? 0
												: $(".bet-choose").length);
								var _index = $(this).parents(".bet-view").attr(
										"data-index");
								$(this).parents(".bet-view")
										.find(".bet-choose").length > 0 ? $(
										".smallround:eq(" + _index + ")")
										.addClass("menus-choose") : $(
										".smallround:eq(" + _index + ")")
										.removeClass("menus-choose");
								var operation = $(this).find(
										".addMoney_contain").css("display");
								if (operation == "block") {
									$(this).find(".addMoney_money").html(
											parseInt($(this).find(
													".addMoney_money").html())
													+ Number(money));
								} else {
									$(this).find(".addMoney_money").html(
											Number(money));
									$(this).find(".addMoney_contain").show();
								}
							}
						} else {
							layer.alert("此类玩法正在维护中……。请选择其它玩法");
						}
					});

	$(".pm-body .lottery-ball").click(
			function() {
				$(this).toggleClass("solid");
				var a = $(this).parents(".role_btn10").find(
						".pm-body .lottery-ball.solid").length;
				var b = 0;
				var c = $(this).parents(".role_btn10").find(".promptbox").attr(
						"id");
				if (c == "box401101001") {// 平码
					if (a >= 2) {
						b = f(a) / (f(a - 2) * f(2));
						if (b >= 35) {
							pmts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401101002") {
					if (a >= 3) {
						b = f(a) / (f(a - 3) * f(3));
						if (b >= 35) {
							pmts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401101003") {
					if (a >= 3) {
						b = f(a) / (f(a - 3) * f(3));
						if (b >= 35) {
							pmts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401201001") {// 定肖中特
					if (a >= 4) {
						b = f(a) / (f(a - 4) * f(4));
					}
				} else if (c == "box401201002") {
					if (a >= 5) {
						b = f(a) / (f(a - 5) * f(5));
					}
				} else if (c == "box401201003") {
					if (a >= 6) {
						b = f(a) / (f(a - 6) * f(6));
					}
				} else if (c == "box401301001") {// 平特肖
					if (a >= 1) {
						b = f(a) / (f(a - 1) * f(1));
					}
				} else if (c == "box401301002") {
					if (a >= 2) {
						b = f(a) / (f(a - 2) * f(2));
					}
				} else if (c == "box401301003") {
					if (a >= 3) {
						b = f(a) / (f(a - 3) * f(3));
					}
				} else if (c == "box401301004") {
					if (a >= 4) {
						b = f(a) / (f(a - 4) * f(4));
					}
				} else if (c == "box401401001") {// 平特尾
					if (a >= 1) {
						b = f(a) / (f(a - 1) * f(1));
					}
				} else if (c == "box401401002") {
					if (a >= 2) {
						b = f(a) / (f(a - 2) * f(2));
					}
				} else if (c == "box401401003") {
					if (a >= 3) {
						b = f(a) / (f(a - 3) * f(3));
					}
				} else if (c == "box401401004") {
					if (a >= 4) {
						b = f(a) / (f(a - 4) * f(4));
					}
				} else if (c == "box401501001") {// 不中
					if (a >= 5) {
						b = f(a) / (f(a - 5) * f(5));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501002") {// 不中
					if (a >= 6) {
						b = f(a) / (f(a - 6) * f(6));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501003") {// 不中
					if (a >= 7) {
						b = f(a) / (f(a - 7) * f(7));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501004") {// 不中
					if (a >= 8) {
						b = f(a) / (f(a - 8) * f(8));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501005") {// 不中
					if (a >= 9) {
						b = f(a) / (f(a - 9) * f(9));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501006") {// 不中
					if (a >= 10) {
						b = f(a) / (f(a - 10) * f(10));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501007") {// 不中
					if (a >= 11) {
						b = f(a) / (f(a - 11) * f(11));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501007") {// 不中
					if (a >= 11) {
						b = f(a) / (f(a - 11) * f(11));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501008") {// 不中
					if (a >= 12) {
						b = f(a) / (f(a - 12) * f(12));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501009") {// 不中
					if (a >= 13) {
						b = f(a) / (f(a - 13) * f(13));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501010") {// 不中
					if (a >= 14) {
						b = f(a) / (f(a - 14) * f(14));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box401501011") {// 不中
					if (a >= 15) {
						b = f(a) / (f(a - 15) * f(15));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				}
				$(this).parents(".role_btn10").find(".box_zs").html(b);
				if (b == 0) {
					$(this).parents(".role_btn10").find(
							".layui-layer-btn .layui-layer-btn0").addClass(
							"buttoncolor");
				} else {
					$(this).parents(".role_btn10").find(
							".layui-layer-btn .layui-layer-btn0").removeClass(
							"buttoncolor");
				}
			});
}
/**
 * 六合彩号码选择提示框
 * 
 * @param wfbm3
 */
function box(wfbm3) {
	layer
			.open({
				type : 1,
				skin : "role_btn10",
				area : '90%',
				shadeClose : true,
				content : $("#box" + wfbm3),
				btn : [ "确定", "取消" ],
				yes : function(index) {
					var b = $("#box" + wfbm3).parents(".role_btn10").find(
							".box_zs").html();
					if (b == 0) {
						$("#" + wfbm3).parents(".bet")
								.removeClass("bet-choose");
						$(".pour-num").html(
								$(".bet-choose").length <= 0 ? 0
										: $(".bet-choose").length);
						var _index = $("#" + wfbm3).parents(".bet-view").attr(
								"data-index");
						$("#" + wfbm3).parents(".bet-view").find(".bet-choose").length > 0 ? $(
								".smallround:eq(" + _index + ")").addClass(
								"menus-choose")
								: $(".smallround:eq(" + _index + ")")
										.removeClass("menus-choose");
					} else {
						$("#" + wfbm3).parents(".bet").addClass("bet-choose");
						$(".pour-num").html(
								$(".bet-choose").length <= 0 ? 0
										: $(".bet-choose").length);
						var _index = $("#" + wfbm3).parents(".bet-view").attr(
								"data-index");
						$("#" + wfbm3).parents(".bet-view").find(".bet-choose").length > 0 ? $(
								".smallround:eq(" + _index + ")").addClass(
								"menus-choose")
								: $(".smallround:eq(" + _index + ")")
										.removeClass("menus-choose");
						layer.close(index);
					}
				},
				btn2 : function(index) {
			// alert(wfbm3);
					$("#box" + wfbm3).parents(".role_btn10").find(".box_zs")
							.html(0);
					$("#box" + wfbm3).parents(".role_btn10").find(
							".pm-body .lottery-ball").removeClass("solid");
					if(wfbm3.length==4){
						var wfbm1 = $("#wfbm1").val();
				// alert("#"+wfbm1 + wfbm3);
						$("#"+wfbm1 + wfbm3).parents(".bet").removeClass("bet-choose");
						$(".pour-num").html($(".bet-choose").length <= 0 ? 0: $(".bet-choose").length);
						var _index = $("#"+wfbm1 + wfbm3).parents(".bet-view").attr("data-index");
						$("#"+wfbm1 + wfbm3).parents(".bet-view").find(".bet-choose").length > 0 ? $(
								".smallround:eq(" + _index + ")").addClass(
								"menus-choose")
								: $(".smallround:eq(" + _index + ")").removeClass(
										"menus-choose");
					}else{
						$("#" + wfbm3).parents(".bet").removeClass("bet-choose");
						$(".pour-num").html(
								$(".bet-choose").length <= 0 ? 0
										: $(".bet-choose").length);
						var _index = $("#" + wfbm3).parents(".bet-view").attr(
								"data-index");
						$("#" + wfbm3).parents(".bet-view").find(".bet-choose").length > 0 ? $(
								".smallround:eq(" + _index + ")").addClass(
								"menus-choose")
								: $(".smallround:eq(" + _index + ")").removeClass(
										"menus-choose");
					}
					layer.close(index);
				}
			});
}

/**
 * 平码提示
 */
function pmts() {
	layer.open({
		type : 1,
		skin : "role_btn12",
		area : '90%',
		shadeClose : true,
		content : $("#pmts_box"),
		time : 1000
	});
};
/**
 * 平特不中提示
 */
function ptbzts() {
	layer.open({
		type : 1,
		skin : "role_btn12",
		area : '90%',
		shadeClose : true,
		content : $("#ptbzts_box"),
		time : 1000
	});
};
// /////////////////////////////////////////////////////////充值////////////////////////////////////////////////////////////////////////////
// 提交充值
function submitCz(zfbm, czfw, online, zflx, domain,ymxs) {
// alert(zfbm+"===="+czfw+"===="+zflx);
	var index1 = load_open();
	var czfws = czfw.split("-");
	var money = $(".coll_body:visible .number input:eq(0)").val();
	var djbh = $(".coll_body:visible .number input:eq(1)").val();
	if (djbh == null || djbh == '' || djbh == undefined) {
		djbh = "^_^";
	}
	if (Number(money) >= Number(czfws[0]) && Number(money) <= Number(czfws[1])) {
		if (online == 0) {
			$.ajax({
				url : "yhzx/selectCZXQmb.do",
				type : "POST",
				data : {
					"SJD" : "SJD",
					"yh" : zfbm,
					"czje" : money,
					"djbh" : djbh
				},
				success : function(result) {
					load_close(index1);
					if(result==6){
						getloginpage();
						return;
					}if (result != '') {
						layer.alert("充值成功！");
					} else {
						layer.alert("充值申请已提交成功！");
						wddp();
// if ($("#ServerUserXxsx").val() == 1) {
							// sendMessageWithType("cz");// 发送充值信息给后台
// }
					}

				},
				error : function(x, h, e) {
					load_closeAll();
				}
			});
		} else {
			var hybm = $("#ServerUserId").val();
// alert(hybm);
			if (hybm == '' || hybm == undefined || hybm == null) {
				load_close(index1);
				getloginpage();
				return;
			}
			if (zflx == 1) {
				var bankId = $(".coll_body:visible .bankId").val();
				if (bankId == "") {
					load_close(index1);
					layer.alert("请先选择银行！！");
					return;
				}
				if(ymxs == 100){
					load_close(index1);
// OpenWindow = window.open(domain
// +"/pay/submitOrder.do?yh="+zfbm+"&czje="+money+"&hybm="+hybm+"&bankId="+bankId,'_self')
// OpenWindow=window.open(domain
// +"/pay/submitOrder.do?yh="+zfbm+"&czje="+money+"&hybm="+hybm+"&bankId="+bankId,
// "newwin", "height=auto,
// width=auto,toolbar=no,scrollbars="+scroll+",menubar=no");
// OpenWindow.document.close();
					window.location.href = domain +"/pay/submitOrder.do?yh="+zfbm+"&czje="+money+"&hybm="+hybm+"&bankId="+bankId;
				}else{
					load_close(index1);
					layer.open({
						type : 2,
						title : '支付',
						shadeClose : true,
						shade : false,
						fix : false,
						// maxmin: true, //开启最大化最小化按钮
						area : [ '100%', '100%' ],
						// content:'keke/backPage.do?zfbm='+zfbm+'&money='+money+"&bankId="+bankId,
						content :  domain +'/pay/submitOrder.do?yh=' + zfbm + '&czje='
								+ money + "&bankId=" + bankId + "&hybm=" + hybm,
						end : function(layero, index) {
							load_closeAll();
// wddp();
						}
					});
				}
			}else if(ymxs == 100){
				load_close(index1);
// window.open(domain
// +"pay/submitOrder.do?yh="+zfbm+"&czje="+money+"&hybm="+hybm+"&bankId="+bankId,'_self')
				OpenWindow=window.open(domain +"/pay/submitOrder.do?yh="+zfbm+"&czje="+money+"&hybm="+hybm, "newwin", "height=auto, width=auto,toolbar=no,scrollbars="+scroll+",menubar=no");
				OpenWindow.document.close();
			}else if(ymxs==9){
				layer.open({
					type : 2,
					title : '支付',
					shadeClose : true,
					shade : false,
					fix : false,
					area : [ '100%', '100%' ],
					content : domain + '/pay/submitOrder.do?yh=' + zfbm+ '&czje=' + money + "&hybm=" + hybm,
					end : function(layero, index) {
						load_closeAll();
// wddp();
					}
				});
			} else if (zflx == 6) {
				layer.open({
					type : 2,
					title : '支付',
					shadeClose : true,
					shade : false,
					fix : false,
					// maxmin: true, //开启最大化最小化按钮
					area : [ '100%', '100%' ],
// content :'/pay/submitOrder.do?yh=' + zfbm+ '&czje=' + money + "&hybm=" +
// hybm,
					content : domain + '/pay/submitOrder.do?yh=' + zfbm+ '&czje=' + money + "&hybm=" + hybm,
					end : function(layero, index) {
						load_closeAll();
// wddp();
					}
				});
			} else if(ymxs==20){
				$.ajax({
					url : "pay/submitOrder.do",
					type : "POST",
					data : {
						"SJD" : "SJD",
						"yh" : zfbm,
						"czje" : money,
						"hybm" : hybm
					},
					dataType : "json",
					success : function(obj) {
						load_close(index1);
						if(obj.status == 2){
							layer.open({
								type : 2,
								title : '支付',
								shadeClose : true,
								shade : false,
								fix : false,
								area : [ '100%', '100%' ],
								content : obj.msg,
								end : function(layero, index) {
									load_closeAll();
								}
							});
						}else{
							layer.alert(obj.msg);
						}
					}
				});
			}else if(zflx==7){
				var bankId = $(".coll_body:visible .bankId").val();
				if (bankId == "") {
					load_close(index1);
					layer.alert("请先选择银行！！");
					return;
				}
				if(ymxs == 100){
					load_close(index1);
// window.open(domain
// +"pay/submitOrder.do?yh="+zfbm+"&czje="+money+"&hybm="+hybm+"&bankId="+bankId,'_self')
					OpenWindow=window.open(domain +"/pay/submitOrder.do?yh="+zfbm+"&czje="+money+"&hybm="+hybm+"&bankId="+bankId, "newwin", "height=auto, width=auto,toolbar=no,scrollbars="+scroll+",menubar=no");
					OpenWindow.document.close();
				}else{
					$.ajax({
						url : "pay/submitOrder.do",
						type : "POST",
						data : {
							"SJD" : "SJD",
							"yh" : zfbm,
							"czje" : money,
							"hybm" : hybm
						},
						dataType : "json",
						success : function(obj) {
							load_close(index1);
							if(obj.status == 3){
// window.open(obj.msg,'_self');
								OpenWindow=window.open(obj.msg, "newwin", "height=auto, width=auto,toolbar=no,scrollbars="+scroll+",menubar=no");
								OpenWindow.document.close();
							}else{
								$("#hymc2").html($("#ServerUserName").val());
								$("#czdh2").html(obj.czdh);
								$("#czje2").html(obj.czje);
								if (obj.status == 1) {
									generateQrcode(obj.msg);
								} else if (obj.status == 2) {
									generateQrcode1(obj.msg);
								}else {
									$("#qrcode").html(obj.msg);
								}
								$("#czdiv1").hide();
								$("#czdiv2").show();
							}
						},
						error : function(x, h, e) {
							load_closeAll();
						}
					});
				}
			}else if (zflx == 8 || zflx==9 || zflx==10) {
				layer.open({
					type : 2,
					title : '支付',
					shadeClose : true,
					shade : false,
					fix : false,
					area : [ '100%', '100%' ],
					content : domain + '/pay/submitOrder.do?yh=' + zfbm+ '&czje=' + money + "&hybm=" + hybm,
					end : function(layero, index) {
						load_closeAll();
					}
				});
			}else {
				$.ajax({
					url : "pay/submitOrder.do",
					type : "POST",
					data : {
						"SJD" : "SJD",
						"yh" : zfbm,
						"czje" : money,
						"hybm" : hybm
					},
					dataType : "json",
					success : function(obj) {
						// console.log(obj);
						load_close(index1);
						if(obj.status == 3){
// window.open(obj.msg,'_self');
							OpenWindow=window.open(obj.msg, "newwin", "height=auto, width=auto,toolbar=no,scrollbars="+scroll+",menubar=no");
							OpenWindow.document.close();
// window.location.href = "'"+obj.msg+"'";
						}else{
							$("#hymc2").html($("#ServerUserName").val());
							$("#czdh2").html(obj.czdh);
							$("#czje2").html(obj.czje);
							if (obj.status == 1) {
								generateQrcode(obj.msg);
							} else if (obj.status == 2) {
								generateQrcode1(obj.msg);
							}else {
								$("#qrcode").html(obj.msg);
							}
							$("#czdiv1").hide();
							$("#czdiv2").show();
						}
					},
					error : function(x, h, e) {
						load_closeAll();
					}
				});
			}
		}
	} else {
		load_close(index1);
		layer.alert("输入范围错误，请重新输入");
	}
}

function czdivfn() {
	$("#czdiv1").show();
	$("#czdiv2").hide();
	$("#czdiv3").hide();
};

function sessionDia() {
	layer.alert("长时间未操作，请重新登录");
	getloginpage();
	return false;
}
/**
 * url 加密
 * 
 * @param url
 */
function generateQrcode(url) {
	var options = {
		render : 'image',
		text : Base64.decode(url),
		size : 180,
		ecLevel : 'M',
		color : '#222222',
		minVersion : 1,
		quiet : 1,
		mode : 0
	};
	$("#qrcode").empty().qrcode(options);
}
/**
 * url 不加密
 * 
 * @param url
 */
function generateQrcode1(url) {
	var options = {
		render : 'image',
		text : url,
		size : 180,
		ecLevel : 'M',
		color : '#222222',
		minVersion : 1,
		quiet : 1,
		mode : 0
	};
	$("#qrcode").empty().qrcode(options);
}

function payalert(message) {
	layer.alert(message);
	wddp();
}

/*
 * 前台充值成功
 */
function sendMessageWithType(ntype) {
	ws.send(JSON.stringify({
		type : ntype,
		nameid : $("#ServerUserId").val(),
		name : $("#ServerUserName").val(),
		userType : 1
	}));
}



// ///////////////////////////////////////////线路检测///////////////////////////////////////////////////////////////
function getXljcUrl(){
	autourl.length = 0;
	$.ajax({
		url : "lottery/getXljcUrl.do",
		type : "POST",
		dataType : "json",
		success : function(result) {
			$.each(result,function(index,item){
				autourl.push(item.WZYM);
			});
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function xljc(){
	$("#xljxlist").html("");
	$("#xljximage").html("");
	xljcfn();
	layer.open({
		type : 1,
		skin : "role_btn5",
		title : false,
		area : [ '90%', '80%' ],
		shadeClose : true,
		content : $("#xiaolubox")
	});
}

function xljcfn(){
	tim=1;
	setInterval("tim++",100);
	b=1;
	butt(autourl);
	run(autourl);
}

function butt(autourl){
	var str = "";
	for(var i=1;i<=autourl.length;i++){
		str +="<li class='kd-menu-item'>"+
				"<span class='nav-line-cell'><i class='icon-nav-cloud'></i></span>"+
				"<span class='kd-textinput nav-line-cell nav-line-time' style='width:40px'><input type='text'  id=txt"+i+" readonly='readonly' value=''></span>"+
				"<span class='kd-textinput nav-line-cell nav-line-url' style='width:120px'><input type='text' id=xlmc"+i+" readonly='readonly' value></span>"+
				"<a id=url"+i+" class='nav-line-cell'><i class='icon icon-nav-visit'></i></a>"+
			"</li>";
	}
	$("#xljxlist").html(str);
}

function auto(url,a){
	$("#url"+b).attr("href",url);
	$("#xlmc"+b).val("线路"+a);
	if(tim>200)
	{$("#txt"+b).val("超时");}
	else
	{$("#txt"+b).val(tim/10+"s")}
	b++
}
function run(autourl){
		var str = "";
		for(var i=1;i<=autourl.length;i++){
			str +="<img src=http://"+autourl[i-1]+"/"+Math.random()+" width=1 height=1 onerror=auto('http://"+autourl[i-1]+"','"+i+"')>";
		}
		$("#xljximage").html(str);
}


// /////////////////////客服/////////////////////////////////////
function getKf() {
	var kftype = $("#kftype").val();
	if(kftype==0){
		$.ajax({
			url : "lottery/getKfdz.do",
			type : "POST",
			dataType : "html",
			success : function(data) {
				window.open(data,'_self');
			},
			error : function(x, h, e) {
				load_closeAll();
			}
		});
	}else{
		load_closeAll();
		var index1= load_open();
		$.ajax({
			url : "lottery/getKf.do",
			type : "POST",
			dataType : "html",
			success : function(data) {
				load_close(index1);
				$("#subContentId").html(data);
				commoninit();
				$("#back").on("click", function() {
					index();
				});
			},
			error : function(x, h, e) {
				load_closeAll();
			}
		});
	}
}




function getQq(){
	var kftype = $("#kftype").val();
	$.ajax({
		url : "lottery/getKfQq.do",
		type : "POST",
		dataType : "html",
		success : function(data) {
			if(kftype==1){
				location.href="mqqwpa://im/chat?chat_type=wpa&uin="+data+"&version=1&src_type=web";
			}else{
 location.href="tencent://message/?uin="+data+"&amp;Site=web&amp;Menu=yes"
// alert(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent));
//				window.open("http://wpa.qq.com/msgrd?v=3&uin="+data+"&site=qq&menu=yes","_blank");
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

function getWx(){
	layer.open({
	  type: 1,
	  title: '微信客服',
	  skin : "role_btn20",
	  area:['80%', '46%'],
	  shadeClose: true,
	  content: $('.kf_wx') //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
	});
}


// /////////////////////////////////////////////////////////////

function div_ggc(context){
	$(".lottery_lose_card .number").html("");
	$(".ggcbackcolor").attr("style","display:none");
	$(".lottery_lose_card .ggcbutton").attr("style","display:none");
	$(".lottery_lose_card .sm-fail").attr("style","display:none");
	$(".lottery_lose_card .dont").attr("style","display:none");
	$(".lottery_lose_card .board").attr("style","display:none");
	var arrays = context.split("|");
	var kjhmStr = arrays[0];
	var zs = arrays[1];
	var zjje = arrays[2];
	init(zs,zjje);
	var kjhmarr = kjhmStr.split(",");
	var str = " <ul>"+
                    "<li><span>"+kjhmarr[0]+"</span></li>"+
                    "<li><span>"+kjhmarr[1]+"</span></li>"+
                    "<li><span>"+kjhmarr[2]+"</span></li>"+
                    "<li><span>"+kjhmarr[3]+"</span></li>"+
                    "<li><span>"+kjhmarr[4]+"</span></li>"+
                "</ul>";
	$(".lottery_lose_card .number").append(str);
    layer.open({
        type: 1,
        skin: "role_btnwin",
        area: ['100%','70%'],
        shadeClose: false,
        content: $(".lottery_lose_card")
    });
	 $('#myCanvas').attr("style","position:absolute");
}


function ggczjts(zs,zjje){
	$(".lottery_lose_card .board").attr("style","display:block");
	if(zs==0){
		$(".lottery_lose_card .sm-fail").attr("style","display:block");
	}else{
		$(".lottery_lose_card .dont").attr("style","display:block");
		$(".lottery_lose_card .dont .order").html("中奖注数<span>"+zs+"</span>注.中奖<span>¥"+zjje+"</span>元");
	}
	$(".lottery_lose_card .ggcbutton").attr("style","display:block");
	getHyje();// 得到会员金额
}



// //////////////////////////////////////////////////////////////////////////////////////////////


function init(zs,zjje) {
	if (!document.getElementById("myCanvas")) {
        var width = "";
        var height = "";
        var canvas = document.createElement("canvas");
        width = "198";
        height = "45";
        canvas.setAttribute("width", width + "px");
        canvas.setAttribute("height", height + "px");
        canvas.setAttribute("style", "border:1px solid green");
        canvas.id = "myCanvas";
        $("#div_canvas").append(canvas);
    }

    var myCanvas = document.getElementById('myCanvas');  
    var ctx = myCanvas.getContext('2d');  
    var mouseDown = false;  
    var mouseIn = false;  
    var width = myCanvas.width;  
    var height = myCanvas.height;  
    var offsetLeft = myCanvas.offsetLeft;  
    var offsetTop = myCanvas.offsetTop;  
    // 先将canvas画上灰色蒙层
    ctx.fillStyle = 'grey';  
    ctx.fillRect(0, 0, width, height);  
    // 此行非常重要，设置再绘制时的显示模式
    ctx.globalCompositeOperation="destination-out";  
    // 随机算是否得奖
// guaguakaContent.innerText = prizeList[0];
    myCanvas.addEventListener('mousedown', function(e){  
      e.preventDefault();  
      mouseDown = true;  
    })  
    myCanvas.addEventListener('touchstart', function(e){  
      e.preventDefault();  
      mouseDown = true;  
    })  
    myCanvas.addEventListener('mouseup', function(e){  
      e.preventDefault();  
      mouseDown = false;  
    })  
    myCanvas.addEventListener('mouseover', function(e){  
      e.preventDefault();  
      mouseIn = true;  
    })  
    myCanvas.addEventListener('mouseout', function(e){  
      e.preventDefault();  
      mouseIn = false;  
    })  
    myCanvas.addEventListener('touchend', function(e){  
      e.preventDefault();  
      mouseDown = false;  
    })  
    myCanvas.addEventListener('mousemove', function(e){  
      var completed = 0;  
      var data = ctx.getImageData(0,0,198,40).data;  
      var total = data.length/4;  
      var i;  
      e.preventDefault();  
      if(!mouseDown || !mouseIn){  
        return;  
      }  
      ctx.beginPath();  
      ctx.arc(e.offsetX, e.offsetY, 10, 0, Math.PI *2)  
      ctx.fill();  
      // 刮的数量到一半时，打印完成刮奖，4个数记录1个相素的rgba值，判断a值为0的超过一半即可
      for(i=3;i<data.length;i+=4){  
        if(data[i] === 0){  
          completed +=1;  
        }  
      }  
      if(completed > total/2){  
// console.log('已完成刮奖');
        ggczjts(zs,zjje);
      }  
    })  
    myCanvas.addEventListener('touchmove', function(e){  
      var rect = e.target.getBoundingClientRect();  
      var completed = 0;  
      var data = ctx.getImageData(0,0,198,40).data;  
      var total = data.length/4;  
      var i;  
      e.preventDefault();  
      if(!mouseDown){  
        return;  
      }  
      ctx.beginPath();  
      ctx.arc(e.targetTouches[0].pageX - rect.left, e.targetTouches[0].pageY - rect.top, 10, 0, Math.PI *2)  
      ctx.fill();  
      // 刮的数量到一半时，打印完成刮奖，4个数记录1个相素的rgba值，判断a值为0的超过一半即可
      for(i=3;i<data.length;i+=4){  
        if(data[i] === 0){  
          completed +=1;  
        }  
      }  
      if(completed > total/2){  
    	  ggczjts(zs,zjje);
      }  
    }) 
}


function alertBind() {
	
}


// ////////////////////////////聊天室////////////////////////////////////////////////////////////////////////


function wfgzfn(cpbm,wfbm1){
	if(event!=null){
		event.stopPropagation();
	}
	var fjbm = cpbm+''+wfbm1;
	if(wfbm1==undefined || wfbm1==null || wfbm1==''){
		wfbm1='';
	}
	if(wfsmObj[fjbm]=='' || wfsmObj[fjbm]==undefined){
		$.ajax({
			url : "wz/cpjs/getCpjsForWfgz.do",
			type : "POST",
			data : {"cpbm":cpbm,"wfbm1":wfbm1},
			dataType : "json",
			success : function(data) {
				if(data.NR==null || data.NR==''){
					layer.alert("请联系客服添加赔率说明");
				}else{
					load_closeAll();
					wfsmObj[fjbm] = data.NR;
					wfgzbox(data.NR);
				}
			},
			error : function(x, h, e) {
				load_closeAll();
			}
		});
	}else{
		load_closeAll();
		wfgzbox(wfsmObj[fjbm]);
	}
};

function wfgzbox(data){
	layer.open({
        type: 1,
        title: '玩法规则',
        skin : "role_btn20",
        area:['99.9%', '99.9%'],
        shadeClose: true,
        content: $("#guize_box").html(data)
    });
}
/**
 * 房间启用禁用
 */
function fjLotteryBtn(wfbm1,fjmoney){
	$.ajax({
		url : "lottery/fjIsQyjy.do",
		type : "POST",
		data : {"wfbm1" : wfbm1},
		success : function(data) {
			// alert(data);
			if(Number(data)==1){
				if(lotteryFjPageObj[wfbm1]!='' && lotteryFjPageObj[wfbm1]!=undefined){
				// alert("==========="+lotteryFjPageObj[wfbm1]);
					$("#subContentId").html(lotteryFjPageObj[wfbm1]);
					commoninit();// 公共部分初始化
					lotteryPage();// 彩种页面
					lotteryBtn();// 彩票按钮初始化
					$("#fjmoney").val(fjmoney);
					fjLotteryInit(wfbm1);// 房间彩票初始化
				}else{
					$.ajax({
						url : "lottery/findFjLottery.do",
						type : "POST",
						data : {"wfbm1" : wfbm1},
						dataType : "json",
						success : function(data) {
							if (data.message == 1) {
								layer.alert("维护中...");
							} else if (data.message == 6) {
								getloginpage();
							} else {
								lotteryFjPageObj[wfbm1]=data.message;
								$("#subContentId").html(data.message);
								commoninit();// 公共部分初始化
								lotteryPage();// 彩种页面
								lotteryBtn();// 彩票按钮初始化
								$("#fjmoney").val(fjmoney);
								fjLotteryInit(wfbm1);// 房间彩票初始化
							}
						},
						error : function(x, h, e) {
							load_closeAll();
						}
					});
				}
			}else if(Number(data)==0){
				layer.alert("维护中。。。");
			}else if(Number(data)==2){
				layer.alert("账户金额不足"+fjmoney+"元，请充值后进入房间");
			}else{
				fjLotteryBtn(wfbm1,fjmoney);
			}
		},
		error : function(x, h, e) {
			layer.alert("网络问题，请重新打开！！");
		}
	});
}


/**
 * 房间彩票初始化
 */
function fjLotteryInit(wfbm1){
	var cpbm = $("#cpbm").val();
	
	$('#getChips').on('click', function () {
	    thirty();
	});
	
	$(".index-back").on('click',function(){
		if(cpbm==51 || cpbm==52 || cpbm==53 || cpbm==54 || cpbm==90 || cpbm==91){
			clickLettoryBtn(cpbm);
		}else{
			index();
		}

	});
	
	// 游戏规则弹框
	$('#yxgz').on('click', function() {
// guize_box();
		wfgzfn(cpbm,1);
	});
	
	getFjCpqhAndTime(cpbm,wfbm1);
	
	getHyje();// 得到金额
	
	
	getFjFooter(wfbm1);

	getFjKjhm(cpbm);
	
// getFjFpxx(wfbm1);//获得房间封盘信息
	
    $(".Collapsing_one").click(function () {
        $(this).toggleClass("current_one").siblings('.Collapsing_one').removeClass("current_one");// 切换图标
        $(this).next(".coll_body").slideToggle(500).siblings(".coll_body").slideUp(500);
    });
}

function thirty() {
    layer.open({
        type: 1,
        skin: "role_btn30",
        title: '投注',
        area:['100%','73%'],
        shadeClose: true,
        scrollbar: false,
        content: $("#us_panel")
    });
}
/**
 * 获得房间封盘信息
 */
function getFjFpxx(wfbm1){
	$.ajax({
		url : "lottery/getFjFpxx.do",
		type : "POST",
		data : {
			"wfbm1" : wfbm1
		},
		dataType : "json",
		success : function(data) {
// console.log("111111"+data);
			return data;
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}


/**
 * 得到房间投注信息
 */
function getFjFooter(wfbm1) {
	if(lotteryObj[wfbm1]!='' && lotteryObj[wfbm1]!=undefined){
		$("#us_panel").html(lotteryObj[wfbm1]);
		footerBtnInit(wfbm1);
	}else{
		$.ajax({
			url : "lottery/getFjFooterText.do",
			type : "POST",
			timeout : timeouttime,
			data : {
				"wfbm1" : wfbm1
			},
			dataType : "json",
			success : function(data) {
				lotteryObj[wfbm1] = data.message;
				$("#us_panel").html(data.message);
				footerBtnInit(wfbm1);
// initButtonWf3Text(); // 选择下注项
			},
			error : function(x, h, e) {
				load_closeAll();
			},
			complete: function (XMLHttpRequest, status) { // 当请求完成时调用函数
		        if (status == 'timeout') {// status ==
											// 'timeout'意为超时,status的可能取值：success,notmodified,nocontent,error,timeout,abort,parsererror
		        	getFjFooter(wfbm1);
		    	}
			}
		});
	}
	

}




/**
 * 得到房间开奖号码
 */
function getFjKjhm(cpbm) {
	$.ajax({
		url : "lottery/getFjKjhm.do",
		type : "POST",
		data : {
			"cpbm" : cpbm
		},
		dataType : "json",
		success : function(data) {
			var str=[];
			if(cpbm==55||cpbm==40 || cpbm==75 || cpbm==76 || cpbm==77){
				// 极速六合彩 六合彩
				$.each(data,function(index,obj){
					str.push("<div class='result-2'>");
					str.push("<span class='result-2-text'>第<span class='text-red'>"+obj.CPQH+"</span>期</span>");
					str.push("<div class='nums-wrap'>");
					str.push("<span class='round bcolor-"+ obj.COLOR1+"'>"+ obj.HM1+ "<p>"+ obj.SX1+ "</p></span>");
					str.push("<span class='round bcolor-"+ obj.COLOR2+"'>"+ obj.HM2+ "<p>"+ obj.SX2+ "</p></span>");
					str.push("<span class='round bcolor-"+ obj.COLOR3+ "'>"+ obj.HM3+ "<p>"+ obj.SX3+ "</p></span>");
					str.push("<span class='round bcolor-"+ obj.COLOR4+ "'>"+ obj.HM4+ "<p>"+ obj.SX4+ "</p></span>");
					str.push("<span class='round bcolor-"+ obj.COLOR5+ "'>"+ obj.HM5+ "<p>"+ obj.SX5+ "</p></span>");
					str.push("<span class='round bcolor-"+ obj.COLOR6+ "'>"+ obj.HM6+ "<p>"+ obj.SX6+ "</p></span>");
					str.push("<span class='round bcolor-blue'>+<p style='color:transparent'>+</p></span>");
					str.push("<span class='round bcolor-"+ obj.COLOR7 + "'>" + obj.HM7 + "<p>"+ obj.SX7 + "</p></span>");
					str.push("</div>");
					str.push("<div style='clear: both;'></div>");
					str.push("</div>");

				});
			}else if(cpbm==56 || cpbm==37 || cpbm ==42 || cpbm ==57 || cpbm == 58 || cpbm==63){
				// 56.极速赛车 37.pk10 42.幸运飞艇 57.房间PK10 58：房间幸运飞艇
				$.each(data,function(index,obj){
					str.push("<div class='result-2'>");
					str.push("<span class='result-2-text'>第<span class='text-red'>"+obj.CPQH+"</span>期</span>");
					str.push("<div class='nums-wrap'>");
					str.push("<span class='round-6 data-" + obj.HM1+ "'>" + obj.HM1 + "</span>");
					str.push("<span class='round-6 data-"+ obj.HM2 + "'>" + obj.HM2 + "</span>");
					str.push("<span class='round-6 data-"+ obj.HM3 + "'>" + obj.HM3 + "</span>");
					str.push("<span class='round-6 data-"+ obj.HM4 + "'>" + obj.HM4 + "</span>");
					str.push("<span class='round-6 data-"+ obj.HM5 + "'>" + obj.HM5 + "</span>");
					str.push("<span class='round-6 data-"+ obj.HM6 + "'>" + obj.HM6 + "</span>");
					str.push("<span class='round-6 data-"+ obj.HM7 + "'>" + obj.HM7 + "</span>");
					str.push("<span class='round-6 data-"+ obj.HM8 + "'>" + obj.HM8 + "</span>");
					str.push("<span class='round-6 data-"+ obj.HM9 + "'>" + obj.HM9 + "</span>");
					str.push("<span class='round-6 data-"+ obj.HM10 + "'>" + obj.HM10+ "</span>");
					str.push("</div><div style='clear: both;'></div>");
					str.push("</div>");
				});
			}else if(cpbm==41||cpbm==45||cpbm==51 || cpbm==52 || cpbm==53 || cpbm==54 || cpbm==90 || cpbm==91){
				// 51.北京28 52.加拿大28 53.重庆28 54.新疆28 41.PC蛋蛋
				$.each(data,function(index,item){
					if(item.DX=='大'){
						var dx = "text-blue";
					}else{
						var dx = "text-red";
					}
					if(item.DS=='单'){
						var ds = "text-blue";
					}else{
						var ds = "text-red";
					}
					var hm1color = getColor(item.HM1);
					var hm2color = getColor(item.HM2);
					var hm3color = getColor(item.HM3);
					var zhcolor="";
					if(cpbm==41){
						zhcolor=getPCddColor(item.HM4);
					}
					zhcolor= getColorZh(item.ZH);
					str.push("<div class='result-2'>");
					str.push("<span class='result-2-text'>第<span class='text-red'>"+item.CPQH+"</span>期</span>");
					str.push("<div class='result-ball'>");
					str.push("<span class='result-normal-kong "+hm1color+"'>"+item.HM1+"</span>");
					str.push("<span>+</span>");
					str.push("<span class='result-normal-kong "+hm2color+"'>"+item.HM2+"</span>");
					str.push("<span>+</span>");
					str.push("<span class='result-normal-kong "+hm3color+"'>"+item.HM3+"</span>");
					str.push("<span>=</span>");
					str.push("<span class='result-normal "+zhcolor+"'>"+item.ZH+"</span>");
					str.push("<span class='daxiao'><span>");
					str.push("(</span><span class='"+dx+"'>"+item.DX+"</span>&nbsp;<span class='"+ds+"'>"+item.DS+"</span><span>)</span></span>");
					str.push("</div><div style='clear: both;'></div>");
					str.push("</div>");
				});
			}else if(cpbm==47 || cpbm==49|| cpbm==50 || cpbm==17|| cpbm==18|| cpbm==19 || cpbm==59 || cpbm==60){
				// 47.分分彩 49.三分彩 17.重庆时时彩 59:房间重庆时时彩 60：房间分分彩
				$.each(data,function(index,item){
					if(item.DX=='大'){
						var dx = "text-blue";
					}else{
						var dx = "text-red";
					}
					if(item.DS=='单'){
						var ds = "text-blue";
					}else{
						var ds = "text-red";
					}
					str.push("<div class='result-2'>");
					str.push("<span class='result-2-text'>第<span class='text-red'>"+item.CPQH+"</span>期</span>");
					str.push("<div class='result-ball'>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM1)+"'>"+item.HM1+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM2)+"'>"+item.HM2+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM3)+"'>"+item.HM3+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM4)+"'>"+item.HM4+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM5)+"'>"+item.HM5+"</span>");
					str.push("<span>=</span>");
					str.push("<span class='result-normal "+getColorZh(item.ZH)+"'>"+item.ZH+"</span>");
					str.push("<span class='daxiao'><span>");
					str.push("(</span><span class='"+dx+"'>"+item.DX+"</span>&nbsp;<span class='"+ds+"'>"+item.DS+"</span><span>)</span></span>");
					str.push("</div><div style='clear: both;'></div>");
					str.push("</div>");
				});
				
				
			}else if(cpbm==20||cpbm==21||cpbm==22||cpbm==23||cpbm==30||cpbm==43||cpbm==44 || cpbm==61||cpbm==66 || cpbm==67 || cpbm==68 || cpbm==69 || cpbm == 70 || cpbm==71){
				// 20.江苏快3 23.北京快3 61:房间江苏快3
				

				$.each(data,function(index,item){
				   var sum=Number(item.HM1)+Number(item.HM2)+Number(item.HM3);

				   str.push("<div>");
				   str.push("<span class='result-2-text' style='line-height:50px;'>第<span class='text-red'>"+item.CPQH+"</span>期</span>");
				   str.push("<div class='nums-wrap' style='float:none'>");
				   str.push("<span class='round-20 data-" + item.HM1+ "'>" + item.HM1 + "</span>");
				   str.push("<span class='round-20 data-"+ item.HM2 + "'>" + item.HM2 + "</span>");
				   str.push("<span class='round-20 data-"+ item.HM3 + "'>" + item.HM3 + "</span>");
				   
				  // str.push("<div>");//str.push("<div
					// class='result-ball'>");
				   str.push("<span style='color:black;background:none;border-radius:unset;margin-right:unset;'>=</span>");
				   str.push("<span style='background:red;margin-right:unset;width:26px;height:26px;line-height:26px;font-size:15px;'>"+sum+"</span>");
				   str.push("<span style='width:10px;color:black;background:none;border-radius:unset;margin-right:unset;'>(</span>");
				   str.push("<span  style='width:15px;height:15px;margin-right:unset;background:none;color:"+(sum>10?'blue':'red')+";'>"+(sum>10?'大':'小')+"</span>&nbsp;<span style='width:15px;height:15px;margin-right:unset;background:none;color:"+(sum%2==0?'red':'blue')+";'>"+(sum%2==0?'双':'单')+"</span>");
				   str.push("<span style='width:10px;color:black;background:none;border-radius:unset;margin-right:unset;'>)</span>");
				   str.push("<div style='clear: both;'></div>");
				   str.push("</div>");
				   
				// str.push("</div>");
				   
				  
				   
				   str.push("</div>");
				   
				   	
					
					
					/*
					 * 
					 * 
					 * 
					 * str.push("</div>");
					 * 
					 * 
					 * str.push("</div>");
					 */
				});
			}else if(cpbm==39 || cpbm==62){
				// 39.幸运农场 62:房间幸运农场
				$.each(data,function(index,item){
					if(item.DX=='大'){
						var dx = "text-blue";
					}else if(item.DX=='小'){
						var dx = "text-red";
					}else{
						var dx = "text-black";
					}
					if(item.DS=='单'){
						var ds = "text-blue";
					}else{
						var ds = "text-red";
					}
					str.push("<div class='result-2'>");
					str.push("<span class='result-2-text'>第<span class='text-red'>"+item.CPQH+"</span>期</span>");
					str.push("<div class='result-ball'>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM1)+"'>"+item.HM1+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM2)+"'>"+item.HM2+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM3)+"'>"+item.HM3+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM4)+"'>"+item.HM4+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM5)+"'>"+item.HM5+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM6)+"'>"+item.HM6+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM7)+"'>"+item.HM7+"</span>");
					str.push("<span class='result-normal-kong "+getNumColor(item.HM8)+"'>"+item.HM8+"</span>");
					str.push("<span>=</span>");
					str.push("<span class='result-normal "+dx+"'>"+item.ZH+"</span>");
					str.push("<span class='daxiao'><span>");
					str.push("(</span><span class='"+dx+"'>"+item.DX+"</span>&nbsp;<span class='"+ds+"'>"+item.DS+"</span><span>)</span></span>");
					str.push("</div><div style='clear: both;'></div>");
					str.push("</div>");

				});
			}
			str.push("<div onclick='getKjjl(5, 1,undefined,undefined,"+cpbm+", undefined,1);' style='color: red;text-align: center;margin: 29px;font-size: 13px;'>点击查看更多开奖记录</div>")
// console.log(str);
			$("#xlkjhm").html(str.join(""));	
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}
function getNumColor(num){
	if(num%2==0){
		return "tt-green";
		
	}else{
		return "tt-red";
	}
}

function getColor(n){
	switch (Number(n)) {
		case 1:
		case 2:
		case 7:
		case 8:
		case 12:
		case 13:
		case 18:
		case 19:
		case 23:
		case 24:
			return "tt-red";
		case 3:
		case 4:
		case 9:
		case 10:
		case 14:
		case 15:
		case 20:
		case 25:
		case 26:
			return "tt-blue";
		case 0:
		case 5:
		case 6:
		case 11:
		case 16:
		case 17:
		case 21:
		case 22:
		case 27:
			return "tt-green";
	}
}
	
function getColorZh(n){
	switch (Number(n)) {
		case 1:
		case 2:
		case 7:
		case 8:
		case 12:
		case 13:
		case 18:
		case 19:
		case 23:
		case 24:
			return "bg-red";
		case 3:
		case 4:
		case 9:
		case 10:
		case 14:
		case 15:
		case 20:
		case 25:
		case 26:
			return "bg-blue";
		case 0:
		case 5:
		case 6:
		case 11:
		case 16:
		case 17:
		case 21:
		case 22:
		case 27:
			return "bg-green";
	}
}

function getPCddColor(num){
	switch (Number(num)) {
	case 3:case 6:case 9:
	case 12:case 15:case 18:
	case 21:case 24:
		return "tt-red";
		
	case 2:case 5:case 8:
	case 11:case 17:case 20:
	case 23:case 26:
		return "tt-blue";
		
	case 1:case 4:case 7:
	case 10:case 16:case 19:
	case 22:case 25:
		return "tt-green";
}
}

function footerBtnInit(wfbm1){
// $('.am-radius').click(function () {
// $('.am-topbar').toggleClass('footerY');
// });
    
// $("#fjtzhm").append(fjxtxx2);
	getFjjlxx(wfbm1);
    
	// 清空
	$(".button-clear").on("click", function() {
		clearData();
	});
    
	$("#doc-ipt-email-1").val($("#fjmoney").val());
// $("#doc-ipt-email-1").val(cj_money);
	
	if(chips_str!=""){
		$("#chipshwb").html(chips_str);
	}
	
	chipSz();// 筹码设置
	showChip();// 筹码选择
	chipFz();// 筹码付值
	/**
	 * 房间追号最小金额
	 */
	$(".bet-min").on('click',function(){
		$("#zhje").val($("#fjmoney").val());
	});
	/**
	 * 房间追号创建单据
	 */
	$(".generate").on('click',function(){
		fjcjzhdj();
	});
	/**
	 * 房间追号下注
	 */
	$("#querenTz").on('click',function(){
		fjzhbetBtn();
	});
	
	/**
	 * 跟投
	 */
    $("#genTou").on('click',function(){
    	getGenTou();
    });
	
	var cpbm = $("#cpbm").val();
	if(cpbm==55 || cpbm==56 ||cpbm==57 || cpbm==58 || cpbm==59 || cpbm==60|| cpbm==61|| cpbm==62 || cpbm==63|| cpbm==75 || cpbm==76 || cpbm==77){
		initJsBut();// 极速左侧按钮初始化
		initButtonWf3Text();
		betBtn();
	}else{
	    $(".bet-daxiao div").click(function () {
	        $(this).toggleClass("ds_ball");
	    })
	    $(".bet_number_box div").click(function () {
	        $(this).toggleClass("ds_ball");
	    })

		fjbetBtn();// 下注
		
		/**
		 * 房间追号对话框
		 */
		$("#room_znumber").on('click',function(){
			if ($(".ds_ball").length != 1) {
				layer.alert('请选择您要下注的选项,并且只能选择一项');
				return false;
			}else{
				$("#zhuiHList").html("");
				$(".zhuiHaoList").attr("style","display:none");
				getZhuiHao();	
			}
		});
		
	    $(".chooseBoll div").on("click", function () {
	        $(".chooseBoll div").removeClass("activeBoll");
	        $(this).addClass("activeBoll");
	        var i=$(this).index();
	        $(".bjeb_dwq").hide();
	        $(".bjeb_dwq").eq(i).show();
	    })
	}
}


function getColorForSsc(parameter){
	switch(parameter%2){
	case 0:
		return 'tt-blue';
		break;
	case 1:
		return 'tt-red';
		break;
	}
}

/**
 * 下注
 */
function fjbetBtn() {
	$('#doc-prompt-toggle').click(function() {
						localArray = [];
						var money = Number($("#doc-ipt-email-1").val());
// alert("===="+money);
						if (money <= 0) {
							layer.alert("请输入下注金额");
							return false;
						}
						if ($(".ds_ball").length <= 0) {
							layer.alert('请选择您要下注的选项');
							return false;
						}
						var pourList = '';
						var pourCount = 0;
						var cpbm = $("#cpbm").val();
						$(".ds_ball").each(function() {
// var title = $(this).attr("title");
// var odds = $(this).find(".bet-item").html();
// var item = $(this).find(".bet-content").html();
							pourCount++;
							var localData = new Object();
							localData.wfmc2 = $("#J_reorder").html();
							localData.wfmc3 = $(this).find("span").html();
							localData.wfbm3 = $(this).find("code").attr("id");
							localData.pl = $(this).find("code").html();
							localData.tzhm = $(this).find("span").html();
							localData.zs = 1;
							localData.price = money;
							localData.cpqh = $(".curIssueNumberId").html();
							localArray.push(localData);
						});
						layerOpenBox(localArray);
					});
}


/*
 * 房间
 */
function sendMessageWithChatRoom(ntype,localArray) {
// console.log(localArray);
	ws.send(JSON.stringify({
		type : ntype,
		nameid : $("#ServerUserId").val(),
		name : $("#ServerUserName").val(),
		userType : 1,
		message:localArray,
		wfbm1:$("#wfbm1").val()
	}));
}

/**
 * 
 * @param message
 */
function setFjCpqhKjhm(message) {
	var messages = message.split("|");
	var obj = messages[2].split(",");
	$("#now_term").html(messages[1]);
	var zh = Number(obj[0])+Number(obj[1])+Number(obj[2]);
	obj.push(zh);
	var dx = "";
	var ds = "";
	var daxiao = "";
	var danshuang = "";
	if(zh>13){
		 dx = "text-red";
		 daxiao = "大";
	}else{
		 dx = "text-blue";
		 daxiao = "小";
	}
	if(zh%2==1){
		 ds = "text-red";
		 danshuang = "单";
	}else{
		 ds = "text-blue";
		 danshuang = "双";
	}
	var hm1color = getColor(obj[0]);
	var hm2color = getColor(obj[1]);
	var hm3color = getColor(obj[2]);
	var zhcolor = getColorZh(zh);
	var str ="<span class='result-normal-kong ball-spo "+hm1color+"'>"+obj[0]+"</span>"+
              "<span>+</span>"+
              "<span class='result-normal-kong ball-spo "+hm2color+"'>"+obj[1]+"</span>"+
              "<span>+</span>"+
              "<span class='result-normal-kong ball-spo "+hm3color+"'>"+obj[2]+"</span>"+
              "<span>=</span>"+
              "<span class='result-normal ball-spo "+zhcolor+"'>"+zh+"</span>"+
              "<span class='daxiao'><span>(</span><span class='"+dx+"'>"+daxiao+"</span>&nbsp;<span class='"+ds+"'>"+danshuang+"</span><span>)</span></span>";
	$("#result-balls").html(str);
	var cpbm = $("#cpbm").val();
	getFjKjhm(cpbm);
	getXtxxKjhm(messages[1],obj);
	// sendMessageWithRobot("robot",$(".curIssueNumberId").html(),$("#wfbm1").val());
}

function setFjCpqhKjhm55(message) {
	var messages = message.split("|");
	var obj = messages[2].split(",");
	var sx = messages[3].split(",");
	$("#now_term").html(messages[1]);
	var str ="<div class='nums-wrap'>" +
			"<span class='round bcolor-"+ jsLhcColor(obj[0])+"'>"+ obj[0]+ "<p>"+ sx[0]+ "</p></span>"+ 
			"<span class='round bcolor-"+ jsLhcColor(obj[1])+"'>"+ obj[1]+ "<p>"+ sx[1]+ "</p></span>"+ 
			"<span class='round bcolor-"+ jsLhcColor(obj[2])+ "'>"+ obj[2]+ "<p>"+ sx[2]+ "</p></span>"+ 
			"<span class='round bcolor-"+ jsLhcColor(obj[3])+ "'>"+ obj[3]+ "<p>"+ sx[3]+ "</p></span>"+ 
			"<span class='round bcolor-"+ jsLhcColor(obj[4])+ "'>"+ obj[4]+ "<p>"+ sx[4]+ "</p></span>"+ 
			"<span class='round bcolor-"+ jsLhcColor(obj[5])+ "'>"+ obj[5]+ "<p>"+ sx[5]+ "</p></span>"+ 
			"<span class='round bcolor-blue'>+<p style='color:transparent'>+</p></span>"+ 
			"<span class='round bcolor-"+ jsLhcColor(obj[6]) + "'>" + obj[6] + "<p>"+ sx[6] + "</p></span>"
			"</div><div style='clear: both;'></div>" +
			"</div>";
	$("#result-balls").html(str);
	var cpbm = $("#cpbm").val();
	getFjKjhm(cpbm);
	getXtxxKjhm55(messages[1],obj);
	// sendMessageWithRobot("robot",$(".curIssueNumberId").html(),$("#wfbm1").val());
}
function jsLhcColor(n){
	switch (Number(n)) {
		case 1:
		case 2:
		case 7:
		case 8:
		case 12:
		case 13:
		case 18:
		case 19:
		case 23:
		case 24:
		case 29:
		case 30:
		case 34:
		case 35:
		case 40:
		case 45:
		case 46:
			return "red";
		case 3:
		case 4:
		case 9:
		case 10:
		case 14:
		case 15:
		case 20:
		case 25:
		case 26:
		case 31:
		case 36:
		case 37:
		case 41:
		case 42:
		case 47:
		case 48:
			return "blue";
		case 5:
		case 6:
		case 11:
		case 16:
		case 17:
		case 21:
		case 22:
		case 27:
		case 28:
		case 32:
		case 33:
		case 38:
		case 39:
		case 43:
		case 44:
		case 49:
			return "green";
	}
}

function setFjCpqhKjhm56(message) {
// console.log("=====setFjCpqhKjhm56======="+message);
	var messages = message.split("|");
	var obj = messages[2].split(",");
	$("#now_term").html(messages[1]);
	var str = "<div class='nums-wrap'>" +
				"<span class='round-6 data-" + obj[0]+ "'>" + obj[0] + "</span>"+ 
				"<span class='round-6 data-"+ obj[1] + "'>" + obj[1] + "</span>"+ 
				"<span class='round-6 data-"+ obj[2] + "'>" + obj[2] + "</span>"+ 
				"<span class='round-6 data-"+ obj[3] + "'>" + obj[3] + "</span>"+ 
				"<span class='round-6 data-"+ obj[4] + "'>" + obj[4] + "</span>"+ 
				"<span class='round-6 data-"+ obj[5] + "'>" + obj[5] + "</span>"+ 
				"<span class='round-6 data-"+ obj[6] + "'>" + obj[6] + "</span>"+ 
				"<span class='round-6 data-"+ obj[7] + "'>" + obj[7] + "</span>"+ 
				"<span class='round-6 data-"+ obj[8] + "'>" + obj[8] + "</span>"+ 
				"<span class='round-6 data-"+ obj[9] + "'>" + obj[9]+ "</span>"+
				"</div>"
	$("#result-balls").html(str);
	var cpbm = $("#cpbm").val();
	getFjKjhm(cpbm);
	getXtxxKjhm56(messages[1],obj);
	// sendMessageWithRobot("robot",$(".curIssueNumberId").html(),$("#wfbm1").val());
}

function setFjCpqhKjhm59(message) {
	var messages = message.split("|");
	var obj = messages[2].split(",");
	$("#now_term").html(messages[1]);
	var zh = Number(obj[0])+Number(obj[1])+Number(obj[2])+Number(obj[3])+Number(obj[4]);
	var color1,color2,color3,color4,color5;
	if(obj[0]%2==0){
		color1 = 'color:blue;border:1px solid #006cc8';
	}else{
		color1 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[1]%2==0){
		color2 = 'color:blue;border:1px solid #006cc8';
	}else{
		color2 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[2]%2==0){
		color3 = 'color:blue;border:1px solid #006cc8';
	}else{
		color3 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[3]%2==0){
		color4 = 'color:blue;border:1px solid #006cc8';
	}else{
		color4 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[4]%2==0){
		color5 = 'color:blue;border:1px solid #006cc8';
	}else{
		color5 = 'color: red;border: 1px solid #ff0000;';
	}
	var str ="<span class='result-normal-kong ball-spo' style='"+color1+"'>"+obj[0]+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+color2+"'>"+obj[1]+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+color3+"'>"+obj[2]+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+color4+"'>"+obj[3]+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+color5+"'>"+obj[4]+"</span>"+
		     "<span>=</span>"+
		     "<span class='result-normal-kong ball-spo'>"+zh+"</span>"+
		     "<span>(</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+(zh>=23?tt_blue():tt_red())+"'>"+(zh>=23?'大':'小')+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+(zh%2==1?tt_blue():tt_red())+"'>"+(zh%2==1?'单':'双')+"</span>"+
		     "<sapn>)</span>";
	$("#result-balls").html(str);
	var cpbm = $("#cpbm").val();
	getFjKjhm(cpbm);
	getXtxxKjhm59(messages[1],obj);
	// sendMessageWithRobot("robot",$(".curIssueNumberId").html(),$("#wfbm1").val());
}

function tt_blue(){
	return 'color:blue;border:1px solid #006cc8';
}

function tt_red(){
	return 'color: red;border: 1px solid #ff0000;';
}

function setFjCpqhKjhm61(message) {
	var messages = message.split("|");
	var obj = messages[2].split(",");
	$("#now_term").html(messages[1]);
	var zh = Number(obj[0])+Number(obj[1])+Number(obj[2]);
	var str ="<div style='float:none'>" +
			"<span class='round-11 data-"+obj[0]+"'>"+obj[0]+"</span>" +
			"<span class='round-11 data-"+obj[1]+"'>"+obj[1]+"</span>" +
			"<span class='round-11 data-"+obj[2]+"'>"+obj[2]+"</span>" +
			"<span>=</span>"+
			"<span class='result-normal-kong ball-spo'>"+zh+"</span>"+
			"<span>(</span>"+
			"<span class='result-normal-kong ball-spo' style='"+(zh>=11?tt_blue():tt_red())+"'>"+(zh>=11?'大':'小')+"</span>"+
			"<span class='result-normal-kong ball-spo' style='"+(zh%2==1?tt_blue():tt_red())+"'>"+(zh%2==1?'单':'双')+"</span>"+
			"<span>)</span>"+
			"</div>";
	$("#result-balls").html(str);
	var cpbm = $("#cpbm").val();
	getFjKjhm(cpbm);
	getXtxxKjhm(messages[1],obj);
	// sendMessageWithRobot("robot",$(".curIssueNumberId").html(),$("#wfbm1").val());
}

function setFjCpqhKjhm62(message) {
	var messages = message.split("|");
	var obj = messages[2].split(",");
	$("#now_term").html(messages[1]);
	var color1,color2,color3,color4,color5,color6,color7,color8;
	if(obj[0]%2==0){
		color1 = 'color:blue;border:1px solid #006cc8';
	}else{
		color1 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[1]%2==0){
		color2 = 'color:blue;border:1px solid #006cc8';
	}else{
		color2 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[2]%2==0){
		color3 = 'color:blue;border:1px solid #006cc8';
	}else{
		color3 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[3]%2==0){
		color4 = 'color:blue;border:1px solid #006cc8';
	}else{
		color4 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[4]%2==0){
		color5 = 'color:blue;border:1px solid #006cc8';
	}else{
		color5 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[5]%2==0){
		color6 = 'color:blue;border:1px solid #006cc8';
	}else{
		color6 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[6]%2==0){
		color7 = 'color:blue;border:1px solid #006cc8';
	}else{
		color7 = 'color: red;border: 1px solid #ff0000;';
	}
	if(obj[7]%2==0){
		color8 = 'color:blue;border:1px solid #006cc8';
	}else{
		color8 = 'color: red;border: 1px solid #ff0000;';
	}
	var str ="<span class='result-normal-kong ball-spo' style='"+color1+"'>"+obj[0]+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+color2+"'>"+obj[1]+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+color3+"'>"+obj[2]+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+color4+"'>"+obj[3]+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+color5+"'>"+obj[4]+"</span>"+
		     "<span class='result-normal-kong ball-spo' style='"+color6+"'>"+obj[5]+"</span>"+
			 "<span class='result-normal-kong ball-spo' style='"+color7+"'>"+obj[6]+"</span>"+
			 "<span class='result-normal-kong ball-spo' style='"+color8+"'>"+obj[7]+"</span>";
	$("#result-balls").html(str);
	var cpbm = $("#cpbm").val();
	getFjKjhm(cpbm);
	getXtxxKjhm62(messages[1],obj);
	// sendMessageWithRobot("robot",$(".curIssueNumberId").html(),$("#wfbm1").val());
}


/**
 * 下期开始
 * 
 * @param cpqh
 * @param obj
 */
function getXtxxXq(cpqh,obj){
	var fjxtxx = "<li class='am-comment' style='margin-top: 0'>"+
	"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
	"<p class='sys-alert'>"+
		"<span class='sys-staus text-blue iottb'>系统消息</span>"+
	    "<span class='sys-text'>"+
	        "<span class='text-light-blue size-change'>["+cpqh+"期]</span>"+
	         "已开启，请投注，祝君财源滚滚"+
	"</p>"+
	"</li>";
// $("#fjtzhm").append(fjxtxx);
	removeFjxx(fjxtxx);
	getScrollAdd();
}

/**
 * 不是这期的彩票期号
 * 
 * @param cpqh
 * @param obj
 */
function getXtxxNotCpqh(cpqh){
	var fjxtxx = "<li class='am-comment' style='margin-top: 0'>"+
	"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
	"<p class='sys-alert'>"+
		"<span class='sys-staus text-blue iottb'>系统消息</span>"+
	    "<span class='sys-text'>"+
	        "<span class='text-light-blue size-change'>["+cpqh+"期]</span>"+
	         "已结束，请重新选择投注"+
	"</p>"+
	"</li>";
// $("#fjtzhm").append(fjxtxx);
	removeFjxx(fjxtxx);
	getScrollAdd();
}

/**
 * 收得开奖号码信息
 * 
 * @param cpqh
 * @param obj
 */
function getXtxxKjhm(cpqh,obj){
	var fjxtxx = "<li class='am-comment' style='margin-top: 0'>"+
	"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
	"<p class='sys-alert'>"+
		"<span class='sys-staus text-blue iottb'>系统消息</span>"+
	    "<span class='sys-text'>"+
	        "<span class='text-light-blue size-change'>["+cpqh+"期]</span>"+
	         "开奖号码:"+obj[0]+"+"+obj[1]+"+"+obj[2]+"="+obj[3]+"</br>" +
	         		"&nbsp;请核对开奖结果，祝君好运;</span>"+
	"</p>"+
	"</li>";
// $("#fjtzhm").append(fjxtxx);
	removeFjxx(fjxtxx);
	getScrollAdd();
}

/**
 * 收得开奖号码信息
 * 
 * @param cpqh
 * @param obj
 */
function getXtxxKjhm55(cpqh,obj){
	var fjxtxx = "<li class='am-comment' style='margin-top: 0'>"+
	"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
	"<p class='sys-alert'>"+
		"<span class='sys-staus text-blue iottb'>系统消息</span>"+
	    "<span class='sys-text'>"+
	        "<span class='text-light-blue size-change'>["+cpqh+"期]</span></br>"+
	         "开奖号码:"+obj[0]+","+obj[1]+","+obj[2]+","+obj[3]+","+obj[4]+","+obj[5]+","+obj[6]+"</br>" +
	         		"&nbsp;请核对开奖结果，祝君好运;</span>"+
	"</p>"+
	"</li>";
// $("#fjtzhm").append(fjxtxx);
	removeFjxx(fjxtxx);
	getScrollAdd();
}

/**
 * 收得开奖号码信息
 * 
 * @param cpqh
 * @param obj
 */
function getXtxxKjhm56(cpqh,obj){
	var fjxtxx = "<li class='am-comment' style='margin-top: 0'>"+
	"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
	"<p class='sys-alert'>"+
		"<span class='sys-staus text-blue iottb'>系统消息</span>"+
	    "<span class='sys-text'>"+
	        "<span class='text-light-blue size-change'>["+cpqh+"期]</span></br>"+
	        "开奖号码:"+obj[0]+","+obj[1]+","+obj[2]+","+obj[3]+","+obj[4]+","+obj[5]+","+obj[6]+","+obj[7]+","+obj[8]+","+obj[9]+"</br>" +
	         		"&nbsp;请核对开奖结果，祝君好运;</span>"+
	"</p>"+
	"</li>";
// $("#fjtzhm").append(fjxtxx);
	removeFjxx(fjxtxx);
	getScrollAdd();
}

function getXtxxKjhm59(cpqh,obj){
	var fjxtxx = "<li class='am-comment' style='margin-top: 0'>"+
	"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
	"<p class='sys-alert'>"+
		"<span class='sys-staus text-blue iottb'>系统消息</span>"+
	    "<span class='sys-text'>"+
	        "<span class='text-light-blue size-change'>["+cpqh+"期]</span></br>"+
	        "开奖号码:"+obj[0]+","+obj[1]+","+obj[2]+","+obj[3]+","+obj[4]+"</br>" +
	         		"&nbsp;请核对开奖结果，祝君好运;</span>"+
	"</p>"+
	"</li>";
// $("#fjtzhm").append(fjxtxx);
	removeFjxx(fjxtxx);
	getScrollAdd();
}

function getXtxxKjhm62(cpqh,obj){
	var fjxtxx = "<li class='am-comment' style='margin-top: 0'>"+
	"<p class='time'><span>系统管理员&nbsp;&nbsp;"+getDate()+"</span></p>"+
	"<p class='sys-alert'>"+
		"<span class='sys-staus text-blue iottb'>系统消息</span>"+
	    "<span class='sys-text'>"+
	        "<span class='text-light-blue size-change'>["+cpqh+"期]</span></br>"+
	        "开奖号码:"+obj[0]+","+obj[1]+","+obj[2]+","+obj[3]+","+obj[4]+","+obj[5]+","+obj[6]+","+obj[7]+"</br>" +
	         		"&nbsp;请核对开奖结果，祝君好运;</span>"+
	"</p>"+
	"</li>";
// $("#fjtzhm").append(fjxtxx);
	removeFjxx(fjxtxx)
	getScrollAdd();
}


/**
 * 调用机器人
 * 
 * @param ntype
 * @param cpqh
 * @param wfbm1
 */
 
function sendMessageWithRobot(ntype,cpqh,wfbm1){
	ws.send(JSON.stringify({
		type : ntype,
		userType : 1,
		cpqh:cpqh,
		wfbm1:wfbm1
	}));
}

/**
 * 房间跟投
 */
function getGenTou(){
	localArray = [];
	$("#gentouCon li").each(function(){
		var localData = new Object();
		localData.wfmc3 = $(this).find(".confirm-text-left").html();
		localData.wfbm3 = $(this).find(".confirm-text-left").attr("data-wfbm3");
		localData.pl = $(this).find(".text-red").attr("data-pl");
		localData.tzhm = $(this).find(".confirm-text-left").html();
		localData.hm = $(this).find(".confirm-text-left1").attr("data-hm");
		localData.zs = 1;
		localData.price = $(this).find(".blue-size").attr("data-price");
		localData.cpqh = $(".curIssueNumberId").html();
		localArray.push(localData);
	});
	submitfn(null,localArray,true);
	localArray = [];
}
/**
 * 获得追号对话框
 */
function getZhuiHao(){
	layer.open({
        type: 1,
        skin: "role_btn40",
        title: '追号',
        area:'auto',
        shadeClose: true,
        content: $(".zhuiHao")
    });
}

/**
 * 房间创建追号单据
 */
function fjcjzhdj(){
	$(".zhuiHaoList").attr("style","display:block");
	localArray = [];
	var str = "";
	var cpqh = $(".curIssueNumberId").html();
	var qs = $("#zhqs").val();
	var bs = $("#zhbs").val();
	var price = $("#zhje").val();
	var sjbs = 1;
	var tzzje = 0;
	var cpqh1 = cpqh.substring(cpqh.length-3);
	var cpqh2 = cpqh.substring(0,cpqh.length-3);
	var cpqh3 = '';
	for(var i=0;i<qs;i++){
		cpqh3 = cpqh2+(Number(cpqh1)+i);
		if(i==0){
			sjbs = sjbs;
		}else{
			sjbs = sjbs*Number(bs);
		}
		str += "<tr data-name='小'>" +
					"<td width='33%'><em>"+cpqh3+"</em></td>" +
					"<td width='33%'><em class='single-money'>"+Number(price)*sjbs+"</em>元</td>" +
					"<td width='33%'><em>"+sjbs+"</em>倍</td>" +
				"</tr>";
		tzzje +=Number(price)*sjbs;
	}
	var localData = new Object();
	localData.tzlx = 2;
	var cpbm = $("#cpbm").val();
	if(cpbm==55 || cpbm ==56 || cpbm==75 || cpbm==76 || cpbm==77){
		localData.wfmc3 = $(".bet-choose").attr("title")+"-"+$(".bet-choose").find(".bet-content").html();
		localData.wfbm3 = $(".bet-choose").find(".bet-item").attr("id");
		localData.pl = $(".bet-choose").find(".bet-item").html();
		localData.tzhm = $(".bet-choose").find(".bet-content").html();
	}else{
		localData.wfmc3 = $(".ds_ball").find("span").html();
		localData.wfbm3 = $(".ds_ball").find("code").attr("id");
		localData.pl = $(".ds_ball").find("code").html();
		localData.tzhm = $(".ds_ball").find("span").html();
	}
	localData.zs = 1;
	localData.bs = bs;
	localData.qs = qs;
	localData.price = price;
	localData.cpqh = cpqh;
	localData.tzzje = tzzje;
	localArray.push(localData);
	
	$("#zhuiHList").html(str);
}

/**
 * 房间追号下注
 */
function fjzhbetBtn(){
	var cpqh = localArray[0].cpqh;
	if(cpqh == $(".curIssueNumberId").html()){
		var a = $("#if_win_stop").is(':checked')
		if(a){
			localArray[0].sftz = 1;
		}else{
			localArray[0].sftz = 0;
		}
		fjSubmitfn(localArray);
	}else{
		getXtxxNotCpqh(cpqh);
	}
}


// 房间追号提交
function fjSubmitfn(localArray) {
	var tzzje = 0;
	$.each(localArray, function(index, item) {
		if (isNaN(item.price) || item.price <= 0 || item.price == ""
				|| !(/^[0-9]+$/.test(item.price))) {
			layer.alert("金额输入有错误,只能整数，请重新输入");
			flag = false;
		} else {
			tzzje = item.tzzje;
		}
	});
	var zhzje = $("#zhzje").text();
	if (tzzje > zhzje) {
		layer.alert("金额不足！！");
		return false;
	}
	var fjmoney = $("#fjmoney").val();
	if(tzzje<fjmoney){
		layer.alert("投注金额 不能小于房间的最小金额");
		return false;
	}
	var cpqh = $(".curIssueNumberId").html();
	var cpbm = $("#cpbm").val();
	var wfbm1 = $("#wfbm1").val();
	var jsonrow = JSON.stringify(localArray);
	load_open();
	var encrypt = new JSEncrypt();
	encrypt.setPublicKey(PUBLIC_KEY);
	$.ajax({
		url : "lottery/save.do",
		type : "POST",
		data : {
			"jsonrow" : base64encode(encodeURIComponent(jsonrow)),
			"tzzje" : encrypt.encrypt(tzzje.toString()),
			"cpbm" : encrypt.encrypt(cpbm),
			"cpqh" : encrypt.encrypt(cpqh),
			"wfbm1": encrypt.encrypt(wfbm1)
		},
		success : function(json) {
			load_closeAll();
			if(json==-1000){
				tisAlert();
				return;
			}
			if (json == 1) {
				getHyje();// 得到会员金额
				if(cpbm==51 || cpbm ==52 || cpbm ==53 || cpbm ==54  || cpbm ==55 || cpbm == 56 || 
						cpbm==57 || cpbm==58 || cpbm==59 || cpbm==60 || cpbm==61 || cpbm==62 || cpbm==75 || cpbm==76 || cpbm==77 || cpbm==90 || cpbm==91){
					
					// sendMessageWithChatRoom("zhchat",localArray);先注释掉
					
				}else{
					div_tzcg();
				}
				showWDXZ();
			} else if (json == 2) {
				layer.alert("封盘中……，请耐心等待");// 投注还没开始，请耐心等待
				// layer.alert("投注还没开始，请耐心等待");// 投注还没开始，请耐心等待
			} else if (json == 3) {
				layer.alert("投注失败！！期号错误，请跟管理员联系！");// 投注失败！！期号错误，请跟管理员联系！
			} else if (json == 4) {
				layer.alert("非法号码！");
			} else if (json == 6) {
				layer.alert("投注超限，请减少投注号码！");
			} else if (json == 7) {
				layer.alert("投注失败");
			} else if (json == 8) {
				getloginpage();
			} else if (json == 9) {
				layer.alert("金额错误，请与管理员联系！");
			}else if (json == 10) {
				layer.alert("数据加密错误，请关机重新启动系统.如再出现些问题，请联系管理员");
			}else if (json == 11) {
				layer.alert("提交过于频繁");
			}else if(json==12){
				layer.alert("不符合本期投注规则，不能同时投注[大,小]");
			}else if(json==13){
				layer.alert("不符合本期投注规则，不能同时投注[单,双]");
			}else if(json==15){
				getloginpage();
			}else if(json==16){
				index();
				layer.alert("此彩种维护中。。。请选择其它彩种");
			} else {
				layer.alert("投注失败，请重新投注");
			}
			localArray = [];
			clearData();
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}


/**
 * 幸运大转盘－－－抽奖
 */
function luckyTurnTable(){
	$.ajax({
		url : "lottery/luckyTurnTable.do",
		type : "POST",
		dataType:"json",
		success : function(data) {
			var  status = data.status;
			if(status=='4'){
				$("#subContentId").html(data.message);
				commoninit();
				$("#look").on("click", function() {
					getZjjl(pagesize, pagenum);
				});
			}else if(status=='1'){
				layer.alert(data.message);
			}else{
				getloginpage();
			}
			
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}
/**
 * 幸运大转盘－－－抽奖记录
 * 
 * @param pagesize
 * @param pagenum
 */
function getZjjl(pagesize, pagenum){
	load_open();
	$.ajax({
		url : "lottery/zjjl.do",
		type : "POST",
		data : {
			"pagesize" : pagesize,
			"pagenum" : pagenum
		},
		success : function(data) {
			load_closeAll();
			var obj = JSON.parse(data);
			$("#subContentId").html(obj.message);
			commoninit();
			getHyje();
			lotteryPage();
			lotteryBtn();
			pager.init();
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

var pager = {
		init : function() {
			$("#first").on("click", function() {
				pager.pagenum = 1;
				if (typeof (pager.doPaging) == "function") {
					pager.doPaging(pager.pagesize, pager.pagenum);
				}
			});

			$("#last").on("click", function() {
				pager.pagenum = pager.tn == 0 ? 1 : pager.tn;
				if (typeof (pager.doPaging) == "function") {
					pager.doPaging(pager.pagesize, pager.pagenum);
				}
			});

			$("#prev").on("click", function() {
				if (pager.tn == 0 || pager.tn == 1) {
					pager.pagenum = 1;
				} else {
					if (pager.pn > 1) {
						pager.pagenum = pager.pn - 1;
					} else {
						pager.pagenum = 1;
					}
				}
				if (typeof (pager.doPaging) == "function") {
					pager.doPaging(pager.pagesize, pager.pagenum);
				}
			});

			$("#next").on("click", function() {
				if (pager.tn == 0 || pager.tn == 1) {
					pager.pagenum = 1;
				} else {
					if (pager.pn < pager.tn) {
						pager.pagenum = pager.pn + 1;
					} else {
						pager.pagenum = pager.pn;
					}
				}
				if (typeof (pager.doPaging) == "function") {
					pager.doPaging(pager.pagesize, pager.pagenum, 1);
				}
			});
			$(".index-back").on('click',function(){
				luckyTurnTable();
			});
		},
		clear : function() {
			pager.pagenum = 1;
			pager.pagesize = 10;
			pager.pn = 0;
			pager.tn = 0;
		},
		doPaging : function() {

		},
		pagesize : 10,
		pagenum : 1,
		pn : 0,
		tn : 0
	};


function initJsBut(){
	// tab切换==玩法1切换
	$(".scroll ul li").click(function() {
		var flag = $(this).attr("isactives");
		if (flag == 1) {
// var a = $("#cpbm").val();
			$(this).addClass('active').siblings().removeClass('active');
			var index = $(this).index();
			number = index;
			$('.content_lc .bet-view').hide();
			$('.content_lc .bet-view:eq(' + index + ')').show();
		} else {
			layer.alert("此玩法在维护中……请选择其它玩法");
		}
	});
	
	/**
	 * 房间追号对话框
	 */
	$("#room_znumber").on('click',function(){
		if ($(".bet-choose").length != 1) {
			layer.alert('请选择您要下注的选项,并且只能选择一项');
			return false;
		}else{
			$("#zhuiHList").html("");
			$(".zhuiHaoList").attr("style","display:none");
			getZhuiHao();	
		}
	});
}
/**
 * 极速六合彩按钮初始化
 */
function jsLhcButtonInit() { 
		
	$(".addMoney_delete")
			.click(
					function(e) {
						e.stopPropagation();
						$(this).parents(".bet").removeClass("bet-choose");
						$(this).parents(".addMoney_contain").hide();
						var _index = $(this).parents(".bet-view").attr(
								"data-index");
						$(this).parents(".bet-view").find(".bet-choose").length > 0 ? $(
								".smallround:eq(" + _index + ")").addClass(
								"menus-choose")
								: $(".smallround:eq(" + _index + ")")
										.removeClass("menus-choose");
					});
	$('.lottery-bet11 .row .bet')
			.on(
					'click',
					function() {
						var money = $("#doc-ipt-email-1").val();
						if (Number(money) == NaN || Number(money) <= 0
								|| !/^[0-9]+$/.test(money)) {
							layer.alert("请先选择金额，金额是整数");
							return;
						}
						$(this).addClass("bet-choose");
						var _index = $(this).parents(".bet-view").attr(
								"data-index");
						var flag = $(".smallround:eq(" + _index + ")").parents(
								".nav").attr("isactives");
						if (flag == 1) {
							var a = $(this).find(".bet-item").attr("id");
							var wfbm3 = a.substring(a.length-4,a.length);
							switch (wfbm3) {
							case '1001':
							case '1002':
							case '1003':
							case '1101':
							case '1102':
							case '1103':
							case '1204':
							case '1205':
							case '1206':
							case '1207':
							case '1301':
							case '1302':
							case '1303':
							case '1304':
							case '1401':
							case '1402':
							case '1403':
							case '1404':
							case '1405':
							case '1406':
							case '1407':
							case '1408':
							case '1409':
							case '1410':
							case '1411':
								box(wfbm3);
								var wfpl2 = $(this).find(".bet-item").attr(
										"wfpl2");
								$("#box" + wfbm3).parents(".role_btn10").find(
										".box_pl").html(wfpl2);
								var b = $("#box" + wfbm3)
										.parents(".role_btn10").find(".box_zs")
										.html();
								if (b == 0) {
									$("#box" + wfbm3)
											.parents(".role_btn10")
											.find(
													".layui-layer-btn .layui-layer-btn0")
											.addClass("buttoncolor");
								} else {
									$("#box" + wfbm3)
											.parents(".role_btn10")
											.find(".layui-layer-btn .layui-layer-btn0")
											.removeClass("buttoncolor");
								}
								break;
							default:
								$(".pour-num").html(
										$(".bet-choose").length <= 0 ? 0
												: $(".bet-choose").length);
								var _index = $(this).parents(".bet-view").attr(
										"data-index");
								$(this).parents(".bet-view")
										.find(".bet-choose").length > 0 ? $(
										".smallround:eq(" + _index + ")")
										.addClass("menus-choose") : $(
										".smallround:eq(" + _index + ")")
										.removeClass("menus-choose");
								var operation = $(this).find(
										".addMoney_contain").css("display");
								if (operation == "block") {
									$(this).find(".addMoney_money").html(
											parseInt($(this).find(
													".addMoney_money").html())
													+ Number(money));
								} else {
									$(this).find(".addMoney_money").html(
											Number(money));
									$(this).find(".addMoney_contain").show();
								}
							}
						} else {
							layer.alert("此类玩法正在维护中……。请选择其它玩法");
						}
					});

	$(".pm-body .lottery-ball").click(
			function() {
				$(this).toggleClass("solid");
				var a = $(this).parents(".role_btn10").find(
						".pm-body .lottery-ball.solid").length;
				var b = 0;
				var c = $(this).parents(".role_btn10").find(".promptbox").attr(
						"id");
				if (c == "box1001") {// 平码
					if (a >= 2) {
						b = f(a) / (f(a - 2) * f(2));
						if (b >= 35) {
							pmts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1002") {
					if (a >= 3) {
						b = f(a) / (f(a - 3) * f(3));
						if (b >= 35) {
							pmts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1003") {
					if (a >= 3) {
						b = f(a) / (f(a - 3) * f(3));
						if (b >= 35) {
							pmts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1101") {// 定肖中特
					if (a >= 4) {
						b = f(a) / (f(a - 4) * f(4));
					}
				} else if (c == "box1102") {
					if (a >= 5) {
						b = f(a) / (f(a - 5) * f(5));
					}
				} else if (c == "box1103") {
					if (a >= 6) {
						b = f(a) / (f(a - 6) * f(6));
					}
				} else if (c == "box1204") {// 平特肖
					if (a >= 1) {
						b = f(a) / (f(a - 1) * f(1));
					}
				} else if (c == "box1205") {
					if (a >= 2) {
						b = f(a) / (f(a - 2) * f(2));
					}
				} else if (c == "box1206") {
					if (a >= 3) {
						b = f(a) / (f(a - 3) * f(3));
					}
				} else if (c == "box1207") {
					if (a >= 4) {
						b = f(a) / (f(a - 4) * f(4));
					}
				} else if (c == "box1301") {// 平特尾
					if (a >= 1) {
						b = f(a) / (f(a - 1) * f(1));
					}
				} else if (c == "box1302") {
					if (a >= 2) {
						b = f(a) / (f(a - 2) * f(2));
					}
				} else if (c == "box1303") {
					if (a >= 3) {
						b = f(a) / (f(a - 3) * f(3));
					}
				} else if (c == "box1304") {
					if (a >= 4) {
						b = f(a) / (f(a - 4) * f(4));
					}
				} else if (c == "box1401") {// 不中
					if (a >= 5) {
						b = f(a) / (f(a - 5) * f(5));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1402") {// 不中
					if (a >= 6) {
						b = f(a) / (f(a - 6) * f(6));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1403") {// 不中
					if (a >= 7) {
						b = f(a) / (f(a - 7) * f(7));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1404") {// 不中
					if (a >= 8) {
						b = f(a) / (f(a - 8) * f(8));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1405") {// 不中
					if (a >= 9) {
						b = f(a) / (f(a - 9) * f(9));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1406") {// 不中
					if (a >= 10) {
						b = f(a) / (f(a - 10) * f(10));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1407") {// 不中
					if (a >= 11) {
						b = f(a) / (f(a - 11) * f(11));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1407") {// 不中
					if (a >= 11) {
						b = f(a) / (f(a - 11) * f(11));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1408") {// 不中
					if (a >= 12) {
						b = f(a) / (f(a - 12) * f(12));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1409") {// 不中
					if (a >= 13) {
						b = f(a) / (f(a - 13) * f(13));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1410") {// 不中
					if (a >= 14) {
						b = f(a) / (f(a - 14) * f(14));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				} else if (c == "box1411") {// 不中
					if (a >= 15) {
						b = f(a) / (f(a - 15) * f(15));
						if (b >= 1000) {
							ptbzts();
							$(this).removeClass("solid");
							return;
						}
					}
				}
				$(this).parents(".role_btn10").find(".box_zs").html(b);
				if (b == 0) {
					$(this).parents(".role_btn10").find(
							".layui-layer-btn .layui-layer-btn0").addClass(
							"buttoncolor");
				} else {
					$(this).parents(".role_btn10").find(
							".layui-layer-btn .layui-layer-btn0").removeClass(
							"buttoncolor");
				}
			});
}


/**
 * 客服
 */
function getZxkf(){
	layer.open({
        type: 1,
        title: '客服',
        skin : "role_btn20",
        area:['80%', '46%'],
        shadeClose: true,
        content: $("#kfbox")
    });
}

	

/**
 * 获得提现
 */
function getTx(){
	var index = load_open();
	$.ajax({
		url : "lottery/txPage.do?type=1",
		type : "POST",
		dataType : "json",
		success : function(data) {
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else if (data.status == "4") {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				zjgl.cztx.init();
			} else if (data.status == "0") {
				alertBind();
			}
			load_close(index);
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}


// 2018-05-19 追号详情begin
function zhtk(contextDiv,showDiv) {
	var wfbm1=$("#wfbm1").val();
  $.ajax({
   url: "lottery/zhjl.do",
   data:{'wfbm1':wfbm1},
	 dataType: "json",
   success: function(res){
		if(res!=""&& res!=null&&res.length>0){
			var innerHtml="";
			
			for(var i=0;i<res.length;i++){
				var zhjl=res[i];
				var detail="";
				// 详情
				for(var j=0;j<zhjl.list.length;j++){
					
				// 追号记录明细
				var zhjlmx=zhjl.list[j];	
				// 投注详情
				var tzxq=zhjlmx.ssctzzb;
				
				detail+="<dd><span>第"+tzxq.cpqh+"期</span><span>"+tzxq.ze*tzxq.bs+"元</span><span>"+tzxq.bs+"倍</span><span style='color:;'>"+(tzxq.tzzt==0?"待开奖":"已开奖")+"</span></dd>";
				}
				
				innerHtml+= "<dl> <dt>"+
				"<span style='width: 60%;'>"+zhjl.zhsj+"</span>"+
// "<span><button class='chedan'
// onclick='chedan('Iim82B',this)'>撤单</button></span>" +
				"</dt>"+
				"<dd style='text-align: center'>"+
				"<span style='width: 100%; text-align: center;'><em>玩法：</em><em style='color: #2aa7f6'>"+zhjl.wfmc3+"</em></span></dd>"+detail+"</dl>";

			}
			
			$("#"+contextDiv).html(innerHtml);
		
			 layer.open({
					type: 1,
					skin: "role_btn60",
					title: '追号详情',
					area:['100%','400px'],
					shadeClose: true,
					content: $("#"+showDiv)
					});
		
		}else{
			layer.msg('暂无数据！');
		}
	 
		  
  }
	
});


}

// 2018-05-19追号详情end
// 开奖预测弹框Index
var kjycIndex=null;
// 开奖预测定时器
var kjycTimer=null;
// 开奖预测倒计时
var kjycCount=0;

// 2018-05-19 开奖预测 begin
function kjyctk(contextDiv,showDiv) {

	createKJYCtxt(contextDiv);
	kjycIndex=layer.open({
		type: 1,
		skin: "role_btnyp",
		title: '开奖预测',
		area: ['100%','435px'],
		shadeClose: true,
		content: $("#"+showDiv)
		,end : function(){ 
			window.clearTimeout(kjycTimer);
		}

	});
}

/**
 * 生成开奖预测html
 */
function createKJYCtxt(contextDiv){
	var cpbm=$("#cpbm").val();
	var wfbm1=$("#wfbm1").val();
	  $.ajax({
		   url: "lottery/getKJYC.do",
		   data:{'wfbm1':wfbm1,'cpbm':cpbm},
			 dataType: "json",
		   success: function(res){
			   var tbody=[];
				if(res!=""&& res!=null&&res.length>0){
					for(i in res){
						
						var item=res[i];
						var kjzt=item.KJZT;		// 开奖状态
						var cpqh=item.CPQH;		// 开奖期号
						var kjsj=item.KJSJ;		// 开奖时间
						var kjhm=[];
						var ycjg=[];// 预测结果
						if(item.KJHM!=undefined||item.KJHM!=null){
							kjhm=item.KJHM.split(",");		// 开奖号码
						}
						
						if(item.KJYC!=undefined||item.KJYC!=null){
							ycjg=item.KJYC.split(",");		// 预测结果
						}

						var str=[];
						if(kjzt!=1){
							str.push("<tr style='width:100%;'>");
							str.push("<td>"+cpqh+"</td>");
							str.push("<td>"+kjsj+"</td>");
							str.push("<td>"+(i==0?"<span id='clock'></span>":"<span >待开奖</span>")+"</td>");
							str.push("<td><span class='label  label-danger'>"+(ycjg.length>0?ycjg[0]:'')+"</span> <span class='label label-danger'>"+(ycjg.length>1?ycjg[1]:'')+"</span></td>");
							str.push("<td></td></tr>");
						}else{
							
							var sum=0;	// 开奖号码总和
							var show="";	// 显示加
							
							$.each(kjhm, function(index, value, array) {
								  sum+=Number(value);
								  show+=show==""?value:"+"+value;
							});
							show=show+"="+sum;
							var kjjg={'dx':sum>13?'大':'小','ds':sum%2==0?'双':'单'};	// 开奖结果
							var dxBoolean=kjjg.dx==ycjg[0]?true:false;	// 大小判断结果
							var dsBoolean=kjjg.ds==ycjg[1]?true:false;	// 单双判断结果
							str.push("<tr>");
							str.push("<td>"+cpqh+"</td>");
							str.push("<td>"+show+"</td>");
							str.push("<td><span class='label  "+(dxBoolean?'label-danger':'label-primary')+"'>"+ycjg[0]+"</span> <span class='label  "+(dsBoolean?'label-danger':'label-primary')+"'>"+ycjg[1]+"</span></td>");
							str.push(" <td><span class='label  "+(dxBoolean||dsBoolean?'label-danger':'label-primary')+"'>"+(dxBoolean||dsBoolean?'对':'错')+"</span></td></tr>");
						}
						tbody.push(str.join(""));;
						
					}
					
					$("#"+contextDiv).html(tbody.join(""));
					
					 // 开启倒计时定时器
					 if(res[0].kjzt!=1){
						 var now=new Date();
						 var ktate=new Date(res[0].KDATE.replace(/-/,"/"));
						 if(now.getTime()<=ktate.getTime()){
							 kjycCount=60;
							 changeTime(ktate);
							 window.clearTimeout(kjycTimer);
							 kjycTimer=setInterval("changeTime('"+ktate+"','"+contextDiv+"')",998);							
						 }
					 }

				}else{
					layer.msg('暂无数据！');
				}
				   
		  }
			
		});
}


// 定时器
function changeTime(date,contextDiv){
	var startTime=new Date();
	 var endTime=new Date(date);
	var second = Math.floor((endTime.getTime()-startTime.getTime())/1000);
	kjycCount--;
	if(second<0||kjycCount<=0){
		createKJYCtxt(contextDiv);
	}else{
		$("#clock").text(second+"s");
	}
	
	
}


// 2018-05-30删除下注begin
var showWDXZistrue=true;

function hidenWDXZ(){
	
	$("#room_delate_xz").html("");
}

// 显示我的下注
function showWDXZ(){

	if($(".room_delete_myxz").length > 0){
		return;
	}
	 var str="<div style='width:100%'><p class='room_delete_myxz' onclick='wdxzClick()'>我的下注</p><img style='float: right; width: 30px; margin-top: 5px;' src='mobil2/images/roomdelete.png'  class='room_delete_main_img' onclick=' hidenWDXZ()'></div>"+
				"<div class='room_delete_xsyc' style='display:none;'>"+	
				"</div>";
          
	$("#room_delate_xz").html(str);
}

function checkWDXZ(cpqh,wfbm1,cpbm){
	if(cpbm==46||$(".room_delete_myxz").length > 0){
		return;
	}
	
	$.ajax({
		type: "POST",
		url: "lottery/checkWDXZ.do",
		data:{'wfbm1':wfbm1,'cpqh':cpqh,'cpzl':cpbm},
		dataType: "json",
		success: function(res){
			if(res!=""&& res!=null&&res>0){
				
				var str="<div style='width:100%'><p class='room_delete_myxz' onclick='wdxzClick()'>我的下注</p> <img style='float: right; width: 30px; margin-top: 5px;' src='mobil2/images/roomdelete.png'  class='room_delete_main_img' onclick=' hidenWDXZ()'></div>"+
				"<div class='room_delete_xsyc' style='display:none;'>"+	
				"</div>";
          
				$("#room_delate_xz").html(str);
		
			}
	 
		  
		}
	
	});		
}

// 我的下注点击事件
function wdxzClick(){
	sendAjax();
	showWDXZistrue=!showWDXZistrue;
$(".room_delete_xsyc").css("display",showWDXZistrue?"none":"block");
}

function sendAjax(){
	if(!showWDXZistrue) return;
	// $(".room_delete_xsyc").html(staticStr+str);
	
	var cpqh=$(".curIssueNumberId").text();
	var wfbm1=$("#wfbm1").val();
	if(cpqh==null || cpqh==undefined || cpqh=='' ){
		return;
	}
						
	$.ajax({
		type: "POST",
		url: "lottery/getByCPQH.do",
		data:{'wfbm1':wfbm1,'cpqh':cpqh},
		dataType: "json",
		success: function(res){
			if(res!=""&& res!=null&&res.length>0){
				var innerHtml="";

				/*
				 * "<div class='room_delete_btn'>"+ "<button>取消本期所有下注</button>"+ "</div>";
				 */
				var str="";
				for(i in res){
					var data=res[i];
					str+="<div class='room_delete_main'>"+
									// "<img src='mobil2/images/roomdelete.png'
									// alt='' class='room_delete_main_img' >"+
									"<em class='cdclose' onclick='cdForTz("+data.sn+","+data.cpzl+")'></em>"+
									"<p>"+data.wfmc23+"</p>"+
								"<div class='room_delete_mainyb'>"+
									"<span>￥"+data.ze*data.bs+"</span>"+
								/*
								 * "<img src='mobil2/images/roomdelete_yb.png'
								 * alt=''>"+
								 */
								"</div>"+
							"</div>";
				}			
				$(".room_delete_xsyc").html(innerHtml+str);
			}else{
// $(".room_delete_xsyc").html("");
				hidenWDXZ();
			}
	 
		  
		}
	
	});					
						
					
						
}

// 删除下注点击事件
function deleteXZ() {
  layer.open({
      type: 1,
      skin: "role_btnscxzk",
      area: '95%',
      shadeClose: false,
      content: $("#room_delate_tk")
  });
}


// 2018-05-30删除下注end


// 2018-06-05 代理盈亏记录

function dlykNext(flag){
	var page=Number(dlykPage);
	var totalPage=Number(total==null?0:total);
	
	if(flag==0){
		page=0;
	}
	else if(flag==1){
		page=page-1;
		if(page<0)return;
		
	}else if(flag==2){
		page=page+1;
		if(page>=totalPage)return;
	}else{
		page=totalPage-1;
	}
	
	
	var kjsj=$("#kssj").val();
	var jssj=$("#jssj").val();
	var hydlmc=$("#hydlmc").val();
	var zxlx = $("#zxlx").val();
	var ywcz = $("#ywcz").val();
	var ykqk = $("#ykqk").val();
		$.ajax({
		type: "POST",
		url: "lottery/dlykPage.do",
		data:{'kjsj':kjsj,'kssj':kjsj,'jssj':jssj,'hydlmc':hydlmc,'zxlx':zxlx,'ywcz':ywcz,'ykqk':ykqk,'page':page+1,'pagecount':dlykPagecount},
		dataType: "json",
		success: function(res){
			var innerHtml="<ul style='border-top:1px solid #ddd;'>"+
							    "<li>用户名</li>"+
							  // "<li>上级</li>"+
							    "<li>充值</li>"+
							    "<li>彩票盈亏</li>"+
							    "<li>明细</li>"+
							"</ul>";
			if(res!=""&& res!=null&&res.list.length>0){
				var list=res.list;
				for(i in list){
					 var str="<ul class='list_number' >" +
					 		"<li class='dlyk_li' onclick='dlykmx("+list[i].hybm+")'>"+list[i].zh+"</li>"+
					 		// "<li>"+list[i].sj+"</li>"+
					 		"<li>"+list[i].cz+"</li>"+
					 		"<li>"+list[i].yk+"</li>"+
					 		"<li onclick='dlykXzjl("+list[i].hybm+")'>查看</li>"+
					 		"</ul>";
					 innerHtml+=str;
				}
				$("#cpyk").html("彩票盈亏："+res.cpyk+"&nbsp;&nbsp;&nbsp;&nbsp;充值盈亏："+res.czyk);
				$("#dlyk_context").html(innerHtml);
				
				$("#pageinfo").text((res.page+1)+"/"+res.totalPage);
				switch(flag){
				case 0:dlykPage=0;break;
				case 1:dlykPage=res.page;break;
				case 2:dlykPage=res.page;break;
				case 3:dlykPage=res.totalPage;break;
				}
				total=res.totalPage;
			}else{
				
				$("#dlyk_context").empty();
				$("#pageinfo").text("0/0"); 
				dlykPage=0;
				total=0;
			}
			}
		
		});		
}

// 2018-06-05 代理盈亏记录


// 2018-06-13 开奖记录


/**
 * 开奖记录
 */
function kjjl(cpbm,page,pagesize){
	cpbm=Number(cpbm);
	pageUtil('pageTool',"lottery/kjjlPage.do",JSON.stringify({'cpzl':cpbm}),function(res){
		 if(res!=null){
					var list=res.list;
					var cpbm=res.para.cpzl;
					var result=getkjjlHtml(cpbm,list);
					$("#kjjl_head").html(result.head);
					$("#kjjl_body1").html(result.body1);
					$("#kjjl_body2").html(result.body2);
					$("#kjjl_body3").html(result.body3);
					
					$(".am-table-tbody").hide();
					$(".am-table-tbody").eq(0).show();
					$(".kjjl_k3_tb_select a").on("click", function () {
					        $(".kjjl_k3_tb_select a").removeClass("active_3jh5tg");
					        $(this).addClass("active_3jh5tg");
					        var i=$(this).index();
					        $(".am-table-tbody").hide();
					        $(".am-table-tbody").eq(i).show();
					    });

			}
	 })

	
}


/**
 * 获取开奖记录Html
 */
function getkjjlHtml(cpbm,list){

		var index=0;
		// 1：PK10 2：快3 3：时时彩 4:28玩法 5：幸运农场 6：六合彩 7：刮刮彩
		
		switch(Number(cpbm)){
		// pk10
		case 37:case 42:case 56:case 57:case 58:case 63:
			index=1;
			break;
		// 快3
		case 20:case 21:case 22:case 23:case 43:case 44:case 61:case 66:case 67:case 68:case 69:case 70:case 71:
			index=2;
			break;
			
		// 时时彩
		case 17:case 18:case 19:case 47:case 49:case 50:case 59:case 60:
			index=3;
			break;
		// 28
		case 45:case 51:case 52:case 53:case 54:case 90:case 91:
			index=4;
			break;
		case 39:case 62:
			index=5;
			break;
		// 六合彩
		case 40:case 55:case 75:case 76:case 77:
			index=6;
			break;
		case 41:// CP蛋蛋
			index=8;
			break;
		// 刮刮彩
		case 46:
			index=7;
			break;
		
			
		}
		var head=getHeadHtml(index);
		var body1=getBody1Html(index,list);
		var body2=getBody2Html(index,list);
		var body3=getBody3Html(index,list);
		return {'head':head,'body1':body1,'body2':body2,'body3':body3};
}

/**
 * 获取表头Html index 1：PK10 2：快3 3：时时彩 4:28玩法 5：幸运农场 6：六合彩 7：刮刮彩 return headString
 */
function getHeadHtml(index){
			// 头部
			var head=[];
			
			head.push("<tr>");
			head.push("<th>期号</th>");
			head.push("<th class='kjjl_k3_tb_select'>");
			head.push("<a role='button' class='active_3jh5tg am-button am-button-small am-button-inline' aria-disabled='false'><span>号 码</span></a>");
			
			switch(index){
			// PK10 头部
			case 1:case 5:
				head.push("<a role='button' class='undefined am-button am-button-small am-button-inline' aria-disabled='false'><span>大 小</span></a>");
				head.push("<a role='button' class='undefined am-button am-button-small am-button-inline' aria-disabled='false'><span>单 双</span></a>");
				head.push("</th>");
				break;
			// 快3
			case 2:case 4:case 7:case 8:
				head.push("<a role='button' class='undefined am-button am-button-small am-button-inline' aria-disabled='false'><span>大 小</span></a>");
				head.push("<a role='button' class='undefined am-button am-button-small am-button-inline' aria-disabled='false'><span>单 双</span></a>");
				head.push("</th>");
				head.push("<th>和</th>");
				head.push("<th>大小</th>");
				head.push("<th>单双</th>");
				break;
			// 时时彩
			case 3:
				head.push("<a role='button' class='undefined am-button am-button-small am-button-inline' aria-disabled='false'><span>大 小</span></a>");
				head.push("<a role='button' class='undefined am-button am-button-small am-button-inline' aria-disabled='false'><span>单 双</span></a>");
				head.push("</th>");
				head.push("<th>前三</th>");
				head.push("<th>中三</th>");
				head.push("<th>后三</th>");
				break;
				
			default :
				head.push("</th>");
				
			}
			
			head.push("</tr>");
			
			return head.join("");
}

/**
 * 获取表格1内容Html index 1：PK10 2：快3 3：时时彩 4:28玩法 5：幸运农场 6：六合彩 7：刮刮彩 dataList 数据
 * return bodyString
 */
function getBody1Html(index,dataList){
	// 表1内容
	var body=[];

	for(var data of dataList){
		// 开奖号码
		var sum=0;
		var kjhm=data.kjhm.split(",");
		kjhm.forEach(function(data,index,arr){  
			sum+=Number(kjhm[index]);
	    }); 
		switch(index){
		// PK10 头部
		case 1:
/*
 * <tr class="am-table-row  am-table-row-level-0"> <td class=""><span
 * class="am-table-row-indent indent-level-0" style="padding-left: 0px;"></span>687064</td>
 * <td class="">开奖中</td> <td class=""></td> <td class=""></td> <td class=""></td>
 * </tr>
 */	
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='nums-wrap' style='float:none'>");
			// 号码
			for(var item of kjhm){
				body.push("<span class='round-6 data-"+item+"'>"+item+"</span>");
			}
			body.push("</div></td>");
			body.push("</tr>");
			
			break;
		// 快3
		case 2:
			
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			body.push("<td class='kjjl_k3_tab'>");
			// 号码
			for(var item of kjhm){
				body.push("<span class='kjjl_bet-content round-11 data-"+item+"' style='color:transparent!important;'>"+item+"</span>");
			}
			body.push("</td>");
			// 单双
			body.push("<td class='kjjl_k3_tab' style='display:none;'>");
			for(var item of kjhm){
				body.push("<span class='kjjl_bet-content round-11 data-"+item+" "+(item%2==0?'even_228g8w\' >双':'odd_ITDw5R\' >单')+"</span>");
			}
			body.push("</td>");
			// 和
			// body.push("<td>"+sum+"</td>");
			// 大小
			if(sum>10&&sum<18){
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong tt-green\">"+sum+"</span></td>");
				body.push("<td><span class='kjjl_bet-content round-11 big_3LK_o6'>大</span></td>");
			}else if(sum>3&&sum<11){
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong tt-red\">"+sum+"</span></td>");
				body.push("<td><span class='kjjl_bet-content round-11 small_1MIJ6I'>小</span></td>");
			}else{
				body.push("<td>"+sum+"</td>");
				body.push("<td><span class='kjjl_bet-content round-11 small_1MIJ6I'>--</span></td>");
			}
			body.push("<td><span class='kjjl_bet-content round-11 "+(sum%2==0?'even_228g8w\'>双':'odd_ITDw5R\'>单')+"</span></td>");
			body.push("</tr>");
			
			break;
		// 时时彩
		case 3:
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='result-ball'  style='width:100%;margin: 0 auto;float: unset;position:relative;top:unset;'>");
			// 号码
			for(var item of kjhm){
				body.push("<span style='float:unset!important;' class=\"result-normal-kong "+(item<5?'tt-red':'tt-green')+"\">"+item+"</span>");
			}
			body.push("</div</td>");
			// 中三 前三 后三
			body.push("<td><span style='color:"+data.qscolor+"'>"+data.qs+"</span></td>");
			body.push("<td><span style='color:"+data.zscolor+"'>"+data.zs+"</span></td>");
			body.push("<td><span style='color:"+data.hscolor+"'>"+data.hs+"</span></td>");
			body.push("</tr>");
			break;
		// 28
		case 4:
		// 刮刮彩
		case 7:
		// PC蛋蛋
		case 8:
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='result-ball' style='width:100%;margin: 0 auto;float: unset;position:relative;top:unset;'>");
			// 号码
			for(var item of kjhm){
				body.push("<span style='float:unset!important;' class=\"result-normal-kong "+(item<5?'tt-red':'tt-green')+"\">"+item+"</span>");
			}
			body.push("</div</td>");
			// 单双
			body.push("<td class='kjjl_k3_tab' style='display:none;'>")
			for(var item of kjhm){
				body.push("<span class='kjjl_bet-content round-11 data-"+item+" "+(item%2==0?'even_228g8w\' >双':'odd_ITDw5R\' >单')+"</span>");
			}
			body.push("</td>");
			// 和
			// body.push("<td>"+sum+"</td>");
			// 大小
			if(index==4){// 28
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong "+getColor(sum)+"\">"+sum+"</span></td>");
				body.push("<td><span  style='float:unset!important;' class=\"kjjl_bet-content round-11 "+(sum>13?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span></td>");
			}else if(index==8){// PC蛋蛋
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong "+getPCddColor(sum)+"\">"+sum+"</span></td>");
				body.push("<td><span class=\"kjjl_bet-content round-11 "+(sum>14?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span></td>");
			}else{// 刮刮彩
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong "+getColor(sum)+"\">"+sum+"</span></td>");
				body.push("<td><span class=\"kjjl_bet-content round-11 "+(sum>22?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span></td>");
			}
			
			body.push("<td><span class=\"kjjl_bet-content round-11 "+(sum%2==0?'even_228g8w\">双':'odd_ITDw5R\">单')+"</span></td>");
			body.push("</tr>");
			break;
		// 幸运农场
		case 5:
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='result-ball' style='width:100%;margin: 0 auto;float: unset;position:relative;top:unset;'>");
			// 号码
			for(var item of kjhm){
				body.push("<span style='float:unset!important;'  class='result-normal-kong "+(item>10?'tt-green':'tt-red')+"\'>"+item+"</span>");
			}
			body.push("</div></td>");
			body.push("</tr>");
			
			break;
		// 六合彩
		case 6:
			var sx=data.sx.split(",");
		
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='kjjl_k3_tab_qh' style=' position: relative; top:-16px;'>"+data.cpqh+"</span></td>");
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='nums-wrap' style='position: relative;top:6px;width: 100%;'>");
			// 号码
			for(var i in kjhm){
				if(i==(kjhm.length-1)){
					body.push("<span class='round bcolor-blue'>+<p style='color:transparent'>+</p></span>");
				}
				body.push("<span class=\"round bcolor-"+getLhcColor(kjhm[i])+"\">"+kjhm[i]+"<p>"+sx[i]+"</p></span>");
			}

			body.push("</div></td>");
			body.push("</tr>");
					
			break;
		
		}
	}
	return body.join("");
}

/**
 * 获取表格2内容Html index 1：PK10 2：快3 3：时时彩 4:28玩法 5：幸运农场 6：六合彩 dataList 数据 return
 * bodyString
 */
function getBody2Html(index,dataList){
	// 表1内容
	var body=[];

	for(var data of dataList){
		// 开奖号码
		var sum=0;
		var kjhm=data.kjhm.split(",");
		kjhm.forEach(function(data,index,arr){   
			sum+=Number(kjhm[index]);
	    }); 
		switch(index){
		// PK10 头部
		case 1:
		// 幸运农场
		case 5:	
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			// 号码
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='nums-wrap'  style='float:none'>");
			for(var item of kjhm){
				// PK10
				if(index==1){
					body.push("<span class=\"round-6 data-"+item+" "+(item>5?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span>");
				}else{
				// 幸运农场
					body.push("<span class=\"round-6 data-"+item+" "+(item>10?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span>");
				}
				
			}
			body.push("</div></td>");
			body.push("</tr>");

			break;
		// 快3
		case 2:
			// 和
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			// 号码
			body.push("<td class='kjjl_k3_tab'>");
			for(var item of kjhm){
				body.push("<span class=\"kjjl_bet-content round-11 data-"+item+" "+(item<4?'small_1MIJ6I\" >小':'big_3LK_o6\" >大')+"</span>");
			}
			body.push("</td>");
			// 大小
			if(sum>10&&sum<18){
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong tt-green\">"+sum+"</span></td>");
				body.push("<td><span class='kjjl_bet-content round-11 big_3LK_o6'>大</span></td>");
			}else if(sum>3&&sum<11){
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong tt-red\">"+sum+"</span></td>");
				body.push("<td><span class='kjjl_bet-content round-11 small_1MIJ6I'>小</span></td>");
			}else{
				body.push("<td>"+sum+"</td>");
				body.push("<td><span class='kjjl_bet-content round-11 small_1MIJ6I'>--</span></td>");
			}
			body.push("<td><span class='kjjl_bet-content round-11 "+(sum%2==0?'even_228g8w\'>双':'odd_ITDw5R\'>单')+"</span></td>");
			body.push("</tr>");
			break;
		// 时时彩
		case 3:
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			// 号码
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='result-ball' style='width:100%;margin: 0 auto;float: unset;position:relative;top:unset;'>");
			for(var i in kjhm){
				body.push("<span  style='float:unset!important;' class=\"result-normal-kong "+(i==0||i==kjhm.length-1?'tt-green':'tt-red')+"  "+(kjhm[i]>4?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span>")
			}
			body.push("</div></td>");	
			body.push("<td><span style='color:"+data.qscolor+"'>"+data.qs+"</span></td>");
			body.push("<td><span style='color:"+data.zscolor+"'>"+data.zs+"</span></td>");
			body.push("<td><span style='color:"+data.hscolor+"'>"+data.hs+"</span></td>");
			body.push("</tr>");
			break;
		// 28
		case 4:
		// 刮刮彩
		case 7:
		// PC蛋蛋
		case 8:
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			// 号码
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='result-ball' style='width:100%;margin: 0 auto;float: unset;position:relative;top:unset;'>");
			for(var i in kjhm){
				body.push("<span style='float:unset!important;' class=\"result-normal-kong "+(i==0||i==kjhm.length-1?'tt-green':'tt-red')+"  "+(kjhm[i]>4?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span>")
			}
			body.push("</div></td>");	
			// body.push("<td>"+sum+"</td>")
			
			if(index==4){// 28
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong "+getColor(sum)+"\">"+sum+"</span></td>");
				body.push("<td><span  style='float:unset!important;' class=\"kjjl_bet-content round-11 "+(sum>13?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span></td>");
			}else if(index==8){// PC蛋蛋
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong "+getPCddColor(sum)+"\">"+sum+"</span></td>");
				body.push("<td><span class=\"kjjl_bet-content round-11 "+(sum>14?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span></td>");
			}else{// 刮刮彩
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong "+getColor(sum)+"\">"+sum+"</span></td>");
				body.push("<td><span class=\"kjjl_bet-content round-11 "+(sum>22?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span></td>");
			}
			
			body.push("<td><span class=\"kjjl_bet-content round-11 "+(sum%2==0?'even_228g8w\">双':'odd_ITDw5R\">单')+"</span></td>")
			body.push("</tr>");
			break;
		
		
		}
	}
	return body.join("");
}


/**
 * 获取表格3内容Html index 1：PK10 2：快3 3：时时彩 4:28玩法 5：幸运农场 6：六合彩 dataList 数据 return
 * bodyString
 */
function getBody3Html(index,dataList){
	// 表1内容
	var body=[];

	for(var data of dataList){
		// 开奖号码
		var sum=0;
		var kjhm=data.kjhm.split(",");
		kjhm.forEach(function(data,index,arr){  
			sum+=Number(kjhm[index]);
	    }); 
		switch(index){
		// PK10 头部
		case 1:
		case 5:	
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			// 单双
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='nums-wrap'  style='float:none'>");
			for(var item of kjhm){
				body.push("<span class=\"round-6 data-"+item+" "+(item%2==0?'odd_ITDw5R\">双':'even_228g8w\">单')+"</span>");
			}
			body.push("</div></td>");
			body.push("</tr>");
			break;
		// 快3
		case 2:
			
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			// 单双
			body.push("<td class='kjjl_k3_tab'>");
			for(var item of kjhm){
				body.push("<span class=\"kjjl_bet-content round-11 data-"+item+" "+(item%2==0?'even_228g8w\" >双':'odd_ITDw5R\" >单')+"</span>");
			}
			body.push("</td>");
			// body.push("<td>"+sum+"</td>");
			// 大小
			if(sum>10&&sum<18){
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong tt-green\">"+sum+"</span></td>");
				body.push("<td><span class='kjjl_bet-content round-11 big_3LK_o6'>大</span></td>");
			}else if(sum>3&&sum<11){
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong tt-red\">"+sum+"</span></td>");
				body.push("<td><span class='kjjl_bet-content round-11 small_1MIJ6I'>小</span></td>");
			}else{
				body.push("<td>"+sum+"</td>");
				body.push("<td><span class='kjjl_bet-content round-11 small_1MIJ6I'>--</span></td>");
			}
			body.push("<td><span class='kjjl_bet-content round-11 "+(sum%2==0?'even_228g8w\'>双':'odd_ITDw5R\'>单')+"</span></td>");
			body.push("</tr>");
			break;
		// 时时彩
		case 3:
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			// 单双
			body.push("<td class='kjjl_k3_tab'>");
			body.push("<div class='result-ball'  style='width:100%;margin: 0 auto;float: unset;position:relative;top:unset;'>");
			for(var i in kjhm){
				body.push("<span style='float:unset!important;' class=\"result-normal-kong "+(i==0||i==kjhm.length?'tt-green':'tt-red')+" "+(kjhm[i]%2==0?'even_228g8w\">双':'odd_ITDw5R\">单')+"</span>");
			}
			body.push("</div></td>");
			body.push("<td><span style='color:"+data.qscolor+"'>"+data.qs+"</span></td>");
			body.push("<td><span style='color:"+data.zscolor+"'>"+data.zs+"</span></td>");
			body.push("<td><span style='color:"+data.hscolor+"'>"+data.hs+"</span></td>");
			body.push("</tr>");
			break;
		// 28
		case 4:
		// 刮刮彩
		case 7:
		// PC蛋蛋
		case 8:
			body.push("<tr class='am-table-row  am-table-row-level-0'>");
			body.push("<td><span class='am-table-row-indent indent-level-0' style='padding-left: 0px;'></span>"+data.cpqh+"</td>");
			// 单双
			body.push("<td class='kjjl_k3_tab'>");

			body.push("<div class='result-ball' style='width:100%;margin: 0 auto;float: unset;position:relative;top:unset;'>");
			for(var i in kjhm){
				body.push("<span style='float:unset!important;' class=\"result-normal-kong "+(i==0||i==kjhm.length?'tt-green':'tt-red')+" "+(kjhm[i]%2==0?'even_228g8w\">双':'odd_ITDw5R\">单')+"</span>");
			}
			body.push("</div></td>");
			// body.push("<td>"+sum+"</td>");
			if(index==4){// 28
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong "+getColor(sum)+"\">"+sum+"</span></td>");
				body.push("<td><span  style='float:unset!important;' class=\"kjjl_bet-content round-11 "+(sum>13?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span></td>");
			}else if(index==8){// PC蛋蛋
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong "+getPCddColor(sum)+"\">"+sum+"</span></td>");
				body.push("<td><span class=\"kjjl_bet-content round-11 "+(sum>14?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span></td>");
			}else{// 刮刮彩
				body.push("<td><span style='border:unset;float:unset!important;' class=\"result-normal-kong "+getColor(sum)+"\">"+sum+"</span></td>");
				body.push("<td><span class=\"kjjl_bet-content round-11 "+(sum>22?'big_3LK_o6\">大':'small_1MIJ6I\">小')+"</span></td>");
			}
			
			body.push("<td><span class=\"kjjl_bet-content round-11 "+(sum%2==0?'even_228g8w\" >双':'odd_ITDw5R\" >单')+"</span></td>");
			body.push("</tr>");
			break;
		
			
		}
	}
	return body.join("");
}


/**
 * 六合彩开奖号码色波
 */
function getLhcColor(n){
	switch (Number(n)) {
		case 1:case 2:case 7:case 8:case 12:
		case 13:case 18:case 19:case 23:case 24:
		case 29:case 30:case 34:case 35:case 40:
		case 45:case 46:
			return "red";
		// return "tt-red";
		
		case 3:case 4:case 9:case 10:case 14:
		case 15:case 20:case 25:case 26:case 31:
		case 36:case 37:case 41:case 42:case 47:	
		case 48:
			return "blue";
			// return "tt-blue";
		
		case 0:case 5:case 6:case 11:case 16:
		case 17:case 21:case 22:case 27:case 28:
		case 32:case 33:case 38:case 39:case 43:
		case 44:case 49:
			return "green";
			// return "tt-green";
	}
}


/**
 * 分页工具 elementID 显示位置 requireUrl 请求路径 para 请求参数{page:1,pagesize:10} Func(res)
 * 回调函数
 */
function pageUtil(showID,requireUrl,para,Func){
	
	if((typeof para)!='object'){
		para=JSON.parse(para);
	}
	if(para.page==null||para.page<1){
		para['page']=1;
	}
		
	if(para.pagesize==null||para.pagesize<1){
		para['pagesize']=10;
	}
		
	var page=Number(para.page);
	var pagesize=Number(para.pagesize);
	
	// 发送Ajax请求 获取服务器数据
	$.ajax({
	type: "POST",
	url:requireUrl,
	data:para,
	async: false,
	dataType: "json",
	success: function(res){
		if(res!=null){
			var pageStr=[];
			var pageCount=Math.ceil(res.count/pagesize);
			pageCount=pageCount==0||pageCount==null?1:pageCount
			var first=para;
			first.page=1;

			pageStr.push("<a class='kd-pager-item first disabled' onclick='pageUtil(&quot;"+showID+"&quot;,&apos;"+requireUrl+"&apos;,"+JSON.stringify(first)+","+Func+")'>&lt;&lt;</a>");
			
			if(page>1){
				var prev=para;
				prev.page=page-1;
				pageStr.push("<a class='kd-pager-item prev disabled'  onclick='pageUtil(&quot;"+showID+"&quot;,&apos;"+requireUrl+"&apos;,"+JSON.stringify(prev)+","+Func+")'>&lt;</a>");
			}else{
				pageStr.push("<a class='kd-pager-item prev disabled' >&lt;</a>");
			}
			
			pageStr.push("<span class='kd-pager-item current'>"+page+" / "+pageCount+"</span>");
			
			if(page<pageCount){
				var next=para;
				next.page=page+1;
				pageStr.push("<a class='kd-pager-item prev disabled'  onclick='pageUtil(&quot;"+showID+"&quot;,&apos;"+requireUrl+"&apos;,"+JSON.stringify(next)+","+Func+")'>&gt;</a>");
			}else{
				pageStr.push("<a class='kd-pager-item prev disabled' >&gt;</a>");
			}
			
			var last=para;
			last.page=pageCount;
			pageStr.push("<a class='kd-pager-item last disabled' onclick='pageUtil(&quot;"+(""+showID)+"&quot;,&quot;"+requireUrl+"&quot;,"+JSON.stringify(last)+","+Func+")'>&gt;&gt;</a>");
			
			if(showID!=null){
				$("#"+showID).html(pageStr.join(""));
			}
			

		}
		if(typeof Func=='function'){
			res.para=para;
			Func(res);
		}
	}
	
	});	

	
}
// 2018-06-13 开奖记录

// 2018-07-04

/**
 * 隐藏下载框
 */
function closeDownload(){
	$(".headTop").hide();
// $("#container1").attr("style","background:#f2f2f2;top:45px");
}
// 2018-07-04

// 撤单
function cdForTz(sn,cpzl){
	layer.confirm('确定撤单？', {
		  btn: ['确认','取消'] // 按钮
		}, function(){
			var index = load_open();
			$.ajax({
						url : "lottery/cd.do",
						type : "POST",
						dataType : "json",
						data : {
							sn : sn,
							cpzl : cpzl
						},
						success : function(data) {
							load_close(index);
							wdxzClick();
							layer.alert(data.message);
						},
						error : function(x, h, e) {
							load_closeAll();
						}
					});
		
		}, function(){
			load_closeAll();
		});
}



// /////////////////////////////////////////登陆存储/////////////////////////////////////////////////////////
function loginLocalstore(){
	if(window.localStorage){
		var storage=window.localStorage;
		$("#username").val(storage.getItem("username"));
		$("#password").val(storage.getItem("password"));
	}
}


// ////////////////////////////----- 2018-07-15 签到功能模块
// -----//////////////////////

// 签到
function signin() {
	var index = load_open();
	$.ajax({
		url : "lottery/signin.do",
		type : "POST",
		success : function(json) {
			load_close(index);
			if(json==-1000){
				tisAlert();
				return;
			}
			var data = JSON.parse(json);
			layer.msg(data.message);
			signData();
			
			// tips.signinAlert(data.message);
				
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}


/**
 * 弹出签到页面
 */
function signPage(a) {
	
	if(a!=1){
		$("#signs").hide();
	}else{
		// $("#signs").show();
		signData();
	}

}
/**
 * 获取签到数据
 */
function signData() {
	var index = load_open();
	$.ajax({
		url : "lottery/signPageData.do",
		type : "POST",
		dataType: "json",
		success : function(res) {
			load_close(index);
			if(res.status==6){
				getloginpage();
				tips.alert(res.message);
			}else if(res.status==1){
				tips.alert(res.message);
			}if(res.status==3){
				var data=res.message;
				var str= createRL(data);
				$(".signs").html(str);
				$("#signs").show();
			}
		}
	});
}


/**
 * 生成日历样式
 */

function createRL(data){
	var list=data.list;
	
	var date=getDateFun();
	var res=[];
	res.push("<div class='checkin'>");
	res.push("<div class='checkin_title'>");
	res.push("<p>"+date.year+"年"+date.month+"月"+date.day+"日, "+weekChange(date.week)+"</p>");
	
	res.push("<p class='sign_sum'>本月已签到<span>"+list.length+"</span>次</p>");
	res.push("</div>");
	res.push("<ul class='week clearfix' style='background: #fff;'>");
	res.push("<li style='width: 41.3695px; height: 41.4286px; box-sizing: border-box; background: rgb(255, 255, 255);'>日</li>");
	res.push("<li style='width: 41.3695px; height: 41.4286px; box-sizing: border-box; background: rgb(255, 255, 255);'>一</li>");
	res.push("<li style='width: 41.3695px; height: 41.4286px; box-sizing: border-box; background: rgb(255, 255, 255);'>二</li>");
	res.push("<li style='width: 41.3695px; height: 41.4286px; box-sizing: border-box; background: rgb(255, 255, 255);'>三</li>");
	res.push("<li style='width: 41.3695px; height: 41.4286px; box-sizing: border-box; background: rgb(255, 255, 255);'>四</li>");
	res.push("<li style='width: 41.3695px; height: 41.4286px; box-sizing: border-box; background: rgb(255, 255, 255);'>五</li>");
	res.push("<li style='width: 41.3695px; height: 41.4286px; box-sizing: border-box; background: rgb(255, 255, 255);'>六</li>");
	res.push("</ul>");
	res.push('<ul class="calendarList clearfix">');
	
	var itemDate=new Date();
	var firstWeek = new Date(itemDate.setDate(1)).getDay(); // 获取本月第一天 星期
	// 填充空白
	for(var i=0;i<firstWeek;i++){
		res.push('<li style="width: 41.3695px; height: 41.4286px; box-sizing: border-box;"></li>');	
	}
	var days=getCountDays();// 获取本月天数
	var drqd=false;
	for(var i=1;i<=days;i++){
		
		var sign=false;	// 签到标记
		
		for(item of list){
			var day=Number(item.qdsj.substr(8,2));
			if(day==i){
				sign=true;
				drqd=(i==new Date().getDate());
				break;
			}
		}
		res.push("<li class='data"+i+(sign?' able-qiandao checked':'')+"\' style='width: 41.3695px; height: 41.4286px; box-sizing: border-box;'>"+i+"</li>");
	}
	// 填充空白
	var endWeek=new Date(new Date(new Date().setMonth(itemDate.getMonth()+1)).setDate(0)).getDay; // 获取最后一天星期
	for(endWeek;endWeek<6;endWeek++){
		res.push('<li style="width: 41.3695px; height: 41.4286px; box-sizing: border-box;"></li>')
	}	
	res.push('</ul>');
	res.push("<button class='checkBtn' href='javascript:;'"+(drqd?"style=\'background: gray;\'":" onclick=\'signin()\'")+">签到</button>");
	res.push('</div>');
	var xycj=data.xycj;
	var qdsz=data.qdsz;
	res.push('<div style="text-align: center;color:#f85456;padding-top:5px;">');
	res.push('<p style="font-size:16px;color:#f85456">当前剩余抽奖次数：'+xycj.cjcs+'；剩余积分：'+xycj.qdjf+'</p>');
	if(qdsz!=null && qdsz.autodh==1){
		res.push('<p style="font-size:16px;color:#f85456">'+qdsz.dhbl+'积分即可自动兑换一次抽奖机会哦！</p>');
	}
	// res.push('<p style="font-size: 12px;color:#f85456">美东时间=北京时间-12小时</p>');
	res.push('</div>');
	
	return res.join("");

}

/**
 * 获取时间
 */
function getDateFun(){
	var date = new Date(); 
	var year=date.getFullYear();// 获取完整的年份(4位,1970-????)
	var month=date.getMonth()+1; // 获取当前月份(0-11,0代表1月)
	var day=date.getDate(); // 获取当前日(1-31)
	var week=date.getDay(); // 获取当前星期X(0-6,0代表星期天)
	var hours=date.getHours(); // 获取当前小时数(0-23)
	var minutes=date.getMinutes();// 获取当前分钟数(0-59)
	var Second=date.getSeconds();// 获取当前秒数(0-59)
	
	var weekName="";

	var res={year:year,month:month,day:day,week:week,hours:hours,minutes:minutes,Second:Second};
	
	return res;
	
}

/**
 * 星期转换
 */
function weekChange(week){
	switch(Number(week)){
		case 1:
			return "星期一";
		case 2:
			return "星期二";
		case 3:
			return "星期三";
		case 4:
			return "星期四";
		case 5:
			return "星期五";
		case 6:
			return "星期六";
		case 0:
			return "星期日";
	}
}

/**
 * 获取月份天数
 */
function getCountDays() {
         var curDate = new Date();
        /* 获取当前月份 */
        var curMonth = curDate.getMonth();
        /* 生成实际的月份: 由于curMonth会比实际月份小1, 故需加1 */
        curDate.setMonth(curMonth + 1);
        /* 将日期设置为0, 这里为什么要这样设置, 我不知道原因, 这是从网上学来的 */
       curDate.setDate(0);
        /* 返回当月的天数 */
        return curDate.getDate();
 }
// ////////////////////////////----- 2018-07-15 签到功能模块
// -----//////////////////////


// ////////////////////////////----- 2018-07-24 签到功能模块
// -----//////////////////////

/**
 * 中奖弹框
 */
// 2018-07-24begin

 function showZJ(zjje) {
	 $(".win-info").html("中奖"+zjje+"元");
     layer.open({
         type: 1,
         skin: "role_btnzj",
         area: ['100%','400px'],
         shadeClose: true,
         content: $(".win-con")
     });
 }
/**
 * 银行卡信息转到修改资料
 */
function getXgzlxx(){
	var khm = $("#khm").val();
	if(khm!='' && khm!=undefined){
		layer.alert("为了您的账户安全,修改姓名请联系客服");
	}else{
		layer.open({
			type : 1,
			skin : "role_btn1",
			title : '提示',
			area : "70%",
			shadeClose : true,
			content : "<span style='font-size: 15px;margin-left: 14px;line-height:77px'>请先正确填写资料，是否跳转</span>",
			btn : [ "是", "否" ],
			yes : function(index) {
				getXgzl();
				layer.close(index);
			},
			btn2 : function(index) {
				layer.close(index);
			}
		});
	}
}
/**
 * 超时提示
 */
function tisAlert(){
	load_closeAll();
	getloginpage();
	layer.alert("长时间未操作，请重新登陆");
}
/**
 * 得到任务
 */
function getRw(){
	var index = load_open();
	$.ajax({
		url : "lottery/getRwsm.do",
		type : "POST",
		dataType: "json",
		success : function(res) {
			load_close(index);
			if(res.status==6){
				getloginpage();
				tips.alert(res.message);
			}else if(res.status==1){
				tips.alert(res.message);
			}if(res.status==3){
				var arr = res.message;
				var str = "";
				if(arr!=null || arr!=''){
					$.each(arr,function(index,obj){
						var a = "";
						if(Number(obj.ISCZ)==1){
							a = "<span style='float:right;color:green'>已完成</span>";
						}else if(Number(obj.ISCZ)==2){
							if(obj.RWSX==1){
								a = "<button style='float:right;color:blue;padding:0px;background-color:#ccc' onclick='getDoRw("+obj.RWSX+")'>去下载</button>";
							}else{
								a = "<button style='float:right;color:blue;padding:0px;background-color:#ccc' onclick='getDoRw("+obj.RWSX+")'>去完成</button>";
							}
							
						}else{
							a = "<span style='float:right;color:red'>未完成</span>";
						}
						str += "<span>"+obj.RWSX+":"+obj.RWSM+"</span>"+a+"</br>";
					});
				}
				layer.alert(str);
			}
		}
	});
}

function getDownAddress(){
	$.ajax({
		url : "lottery/getDownAddress.do",
		type : "POST",
		dataType: "json",
		success : function(res) {
			if(res.status==3){
				window.open(res.message,'_self')
			}else{
				layer.alert("请到浏览器首页下载");
			}
		}
	});
}
/**
 * 去做任务
 */
function getDoRw(rwsx){
	load_closeAll();
	if(rwsx==1){
		getDownAddress();
	}else if(rwsx==2){
		getYhkxx();
	}else if(rwsx==3){
		getCztxInFooter();
	}else if(rwsx==4){
		index();
	}else if(rwsx==5){
		getCztxInFooter();
	}
}

/**
 * 代理盈亏明细
 */
function dlykXzjl(hybm){
	var cheng = load_open();
	var kssj = $("#kssj").val();
	var jssj = $("#jssj").val();
	$.ajax({
		url : "lottery/dlykXzjl.do",
		type : "POST",
		dataType : "json",
		data :{"hybm":hybm,"kssj":kssj,"jssj":jssj},
		success : function(data) {
			var obj = JSON.parse(data.message);
			$("#dlykxzjlzj").text(obj.zj);
			$("#dlykxzjlzyk").text(obj.zyk);
			var array = obj.list;
			var str = "";
			if(array!="" && array!=undefined){
				$.each(obj.list,function(index,item){
				// console.log(item);
					var ykje = item.ykje;
					if(ykje>=0){
						ykje = "<td style='border:1px solid #000;color:red'>￥"+item.ykje+"</td>"
					}else if(ykje<0){
						ykje = "<td style='border:1px solid #000;color:green'>￥"+item.ykje+"</td>"
					}else if((ykje==undefined || ykje=='')&& item.tzzt==0){
						ykje = "<td style='border:1px solid #000;color:blue'>未开奖</td>"
					}else{
						ykje = "<td style='border:1px solid #000;color:blue'>已撤单</td>"
					}
					str += "<tr class='betrecord_xz'>"+
						  "<td style='border:1px solid #000;'>"+item.cpmc+"<br/>"+item.cpqh+"</td>"+
						  "<td style='border:1px solid #000;'>"+item.wfmc3+"<br/>￥"+item.ze+"</td>"+
						  ykje+
						  "<td style='border:1px solid #000;'>"+item.cjsj+"</td>"+
						  "</tr>";
				});
			}
			$("#dlykxzjltbody").empty();
			$("#dlykxzjltbody").append(str);
			load_close(cheng);
			layer.open({
		        type: 1,
		        skin:"",
		        title : '当前时间投注统计和前100注明细',
		        area: ['100%','100%'],
		        shadeClose: true,
		        content: $("#grykxzjl")
		    });
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}

/** *====================20190323修改===========================** */

function getIsgfmm(){
	$.ajax({
		url : "lottery/getIsgfmm.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			if(Number(data)==0){
				getMmggTsxx();
			}
		}
	});
}



// 密码更改提示信息
function getMmggTsxx(){
	layer.open({
		type : 1,
		skin : "role_btn21",
		title : '提示',
		area : "80%",
		shadeClose : true,
		content : "<span style='color: rgb(51, 51, 51); font-size: 14px; line-height: normal;'>尊敬的会员您好，为加强您在平台个人信息的安全性，我司技术升级了密码加密系统，请您及时修改登陆密码【注：修改的登陆密码不得与之前登陆密码一样，支付密码默认与本次更改的登陆密码一致】，更改密码不影响您在平台的任何游戏体验，感谢您长期对平台的理解与支持，祝您购彩愉快。</span>",
		btn : [ "马上去"],
		yes : function(index) {
			getXgzlXgmm();
			layer.close(index);
		}
	});
}

// 进入修改资料＝＝＝修改密码
function getXgzlXgmm() {
	var index = load_open();
	$.ajax({
		url : "lottery/xgzl.do",
		type : "POST",
		dataType : "json",
		success : function(data) {
			load_close(index);
			if(data==-1000){
				tisAlert();
				return;
			}
			if (data.status == "6") {
				getloginpage();
			} else if (data.status == "1") {
				tips.alert(data.message);
			} else {
				$("#subContentId").empty();
				$("#subContentId").append(data.message);
				commoninit();
				member.xgzl.init();
				
				$("#container1 ul li").removeClass("router-link-exact-active");
				$("#container1 ul li").removeClass("active");
				$("#container1 ul li").eq(1).addClass("router-link-exact-active");
				$("#container1 ul li").eq(1).addClass("active");
				$("form").hide();
				$("form").eq(1).show();
			}
		},
		error : function(x, h, e) {
			load_closeAll();
		}
	});
}
